我想添加可排序标题到h:dataTable。我试图按照http://balusc.blogspot.com/2006/06/using-datatables.html来做到这一点。以下呈现链接,但它什么都不做。JSF 2.0可排序标题与h:datatable
list.xhtml
<h:dataTable value="#{iptableController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
<h:column>
<f:facet name="header">
<h:commandLink actionListener="#{iptableController.sortDataList}">
<f:attribute name="sortField" value="getID"/>
<h:outputText value="#{bundle.ListIptableTitle_iptableId}"/>
</h:commandLink>
</f:facet>
<h:outputText value="#{item.iptableId}"/>
</h:column>
这是我试图使用的控制器的一部分。
iptableController
public void sortDataList(ActionEvent event) {
String sortFieldAttribute = getAttribute(event, "sortField");
// Get and set sort field and sort order.
if (sortField != null && sortField.equals(sortFieldAttribute)) {
sortAscending = !sortAscending;
} else {
sortField = sortFieldAttribute;
sortAscending = true;
}
// Sort results.
if (sortField != null) {
Collections.sort(getFacade().findAll(), new DTOComparator(sortField, sortAscending));
}
}
DTOCompartor与链接中的DTOCompartor完全相同。
我觉得我已经完全走错了路,但一直无法找到更好的指导。任何帮助都将不胜感激。
编辑:
我打开了更精细的过滤,并能够看到一个问题。我不确定是什么原因造成的,但看起来控制器正在被添加两次,并被分配到<error>.
包。我重命名了该文件,并已解决。清理一些其他问题(调用不存在的功能等)后,我坚持用错误:
SEVERE: JSF1073: javax.faces.event.AbortProcessingException caught during processing of INVOKE_APPLICATION 5 : UIComponent-ClientId=j_idt12:j_idt22, Message=/iptable/List.xhtml @26,88 actionListener="#{Controller.sortList}": java.lang.RuntimeException: Cannot compare test, test with t, test1 on [getiptableID]
SEVERE: /iptable/List.xhtml @26,88 actionListener="#{Controller.sortList}": java.lang.RuntimeException: Cannot compare test, test with t, test1 on [getiptableID]
在DTOComparator评论指出://如果出现这种异常,那么它通常是一个错误的DTO开发人员。
我干将看起来都像:
public String getIptableName() {
return iptableName;
}
感谢您的快速响应。 list.xhtml定义了一个表单:。 我检查了您提供的链接中的1-3,我很确定这些都没有发生。我不知道如何检查4-7。 这里是完整的文件:http://pastebin.com/S4hpS1Gg 和完整的控制器:http://pastebin.com/Kz6T3UZE 完整的实体:http://pastebin.com/6tN93Dui –
duallain
2010-06-23 21:24:40
然后它应该有完成*某事*。服务器是否被打过? JSF生命周期的哪些阶段已被处理? – BalusC 2010-06-23 21:27:14
我已经在上面添加了更多信息。它正在击中服务器,只是没有对我做任何可见的事情。 – duallain 2010-06-23 23:08:02