Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF 2.0 Sortable headers with h:datatable
    primarykey
    data
    text
    <p>I'm trying to add sortable headers to an h:dataTable. I'm attempting to follow <a href="http://balusc.blogspot.com/2006/06/using-datatables.html" rel="nofollow noreferrer">http://balusc.blogspot.com/2006/06/using-datatables.html</a> to do this. The following renders a link but it doesn't do anything.</p> <pre><code>list.xhtml &lt;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"&gt; &lt;h:column&gt; &lt;f:facet name="header"&gt; &lt;h:commandLink actionListener="#{iptableController.sortDataList}"&gt; &lt;f:attribute name="sortField" value="getID"/&gt; &lt;h:outputText value="#{bundle.ListIptableTitle_iptableId}"/&gt; &lt;/h:commandLink&gt; &lt;/f:facet&gt; &lt;h:outputText value="#{item.iptableId}"/&gt; &lt;/h:column&gt; </code></pre> <p>Here is the a portion of the controller I'm trying to use.</p> <pre><code>iptableController public void sortDataList(ActionEvent event) { String sortFieldAttribute = getAttribute(event, "sortField"); // Get and set sort field and sort order. if (sortField != null &amp;&amp; sortField.equals(sortFieldAttribute)) { sortAscending = !sortAscending; } else { sortField = sortFieldAttribute; sortAscending = true; } // Sort results. if (sortField != null) { Collections.sort(getFacade().findAll(), new DTOComparator(sortField, sortAscending)); } } </code></pre> <p>The DTOCompartor is identical to the one in the link.</p> <p>I feel like I've gone down the wrong path completely, but have been unable to find a better guide. Any help at all would be appreciated.</p> <p>EDIT: </p> <p>I turned on finer filtering and was able to see a problem. I'm not sure what was causing it, but it looks like the controller was being added twice and was allocated to the <code>&lt;error&gt;.</code> package. I renamed the file and that was resolved. After cleaning up a few other issues (calling non-existant functions etc) I'm stuck with the error: </p> <pre><code>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] </code></pre> <p>the comment in DTOComparator indicates that: // If this exception occurs, then it is usually a fault of the DTO developer.</p> <p>my getters all look like:</p> <pre><code>public String getIptableName() { return iptableName; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload