0
我使用的是JSF2.2和Richfaces 4,我尝试使用Jquery的Datatables创建一个表。 因为我所有的数据都是动态的,所以我必须使用它。 但它给了我一个jsf空表。为什么JQuery数据表不能使用richfaces <a4j:repeat>?
这是我的JSF页面:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:p="http://java.sun.com/jsf/passthrough"
xmlns:rich="http://richfaces.org/rich">
<h:head>
<script type="text/javascript" src="js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css"/>
<script>
$(document).ready(function() {
$('#example').dataTable();
});
</script>
</h:head>
<h:body>
<h:form>
<h:panelGroup id="tableau">
<table id="example" class="display compact" cellspacing="0"
width="100%">
<a4j:repeat value="#{auditController.findAllEntityList()}"
var="entity" rowKeyVar="rowentity">
<thead>
<tr>
<a4j:repeat
value="#{Controller.findP(entity).entrySet().toArray()}"
var="entete1">
<th><h:outputLabel value="#{entete1.key}"
rendered="#{rowentity eq 0 and entete1.key !='class'}" /></th>
</a4j:repeat>
</tr>
</thead>
<tbody>
<tr>
<a4j:repeat
value="#{Controller.findP(entity).entrySet().toArray()}"
var="entete">
<td><h:outputLabel value="#{entete.value}"/></td>
</a4j:repeat>
</tr>
</tbody>
</a4j:repeat>
</table>
</h:panelGroup>
</h:form>
</h:body>
没有jQuery的它完美的作品。
看,如果源代码包含您的数据。也许这只是一个CSS问题。并不'jquery.dataTables'需要'jquery'也被加载? – 2015-02-12 08:49:58
正如我所说的,当我使用一个html表格时,jsf向我显示该表格与来自我的javabean的数据,但是当我使用数据表格时,情况并非如此。 我认为它不兼容像这样的richfaces组件,不是吗? 注意:使用数据库,它为我提供了一个没有jQuery功能的小型css表格。 –
TinyOS
2015-02-12 09:25:53
'A4J'将完成它的工作来创建页面HTML。一旦完成并且HTML被完全加载,'jquery'就会开始工作。所以我唯一可以看到的问题是所创建的HTML与您的调用不兼容。 (或者jquery库加载不好) – 2015-02-12 09:38:13