Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay all rows in tomahawk paginated, sortable datatable
    text
    copied!<p>I'm trying to create a paginated, sortable datatable using <strong>MyFaces</strong>. The sorting works fine; I can click on a column header and it will sort the data based on the column. Also the pagination works fine for the most part. The datatable will split itself appropriately with some number of items per page. In addition, I want the user to be able to change the number of items displayed per page. Again, this seems to be working until I want all of the items displayed on one page.</p> <p>According to this <a href="http://myfaces.apache.org/tomahawk-project/tomahawk/tagdoc/t_dataTable.html" rel="nofollow">reference</a> (also <a href="http://www.developersbook.com/jsf/myfaces/tomahawk-tag-reference/tomahawk-dataTable.php" rel="nofollow">here</a>), if you set the "rows" attribute of <strong>t:datatable</strong> to "0", it will display the remaining rows in the table. However, when I try this, I get an exception that includes this message: </p> <pre><code>javax.faces.FacesException - You need to set a value to the 'rows' attribute of component 'myComponent' </code></pre> <p>I'm trying to set the number of items per page using an attribute in a backing bean. My <strong>t:datatable</strong> looks like this:</p> <pre><code>&lt;t:dataTable id="myComponent" var="cur" value="#{backingBean.list}" sortAscending="#{backingBean.ascending}" sortColumn="#{backingBean.sortColumn}" sortable="true" styleClass="myClass" rowClasses="oddRow,evenRow" rows="#{backingBean.itemsPerPage}" preserveDataModel="false"&gt; &lt;!-- data here --&gt; &lt;/t:datatable&gt; </code></pre> <p>Later, I have a <strong>t:dataScroller</strong> to control the pagination:</p> <pre><code>&lt;t:dataScroller id="pageNavigation" for="myComponent" paginatorActiveColumnStyle="font-weight:bold;" renderFacetsIfSinglePage="false" binding="#{backingBean.scroller}" paginator="true" &gt; &lt;!-- facets here --&gt; &lt;/t:dataScroller&gt; </code></pre> <p>Then, I have a <strong>h:selectOneMenu</strong> to select the number of items per page</p> <pre><code>&lt;h:selectOneMenu id="myScroller" value="#{backingBean.itemsPerPage}" required="true" onchange="this.form.submit();" valueChangeListener="#{backingBean.updateItemsPerPage}"&gt; &lt;f:selectItems value="#{backingBean.itemsPerPageArray}" /&gt; &lt;/h:selectOneMenu&gt; </code></pre> <p>My backing bean looks something like this:</p> <pre><code>public class BackingBean { private boolean ascending; private Long itemsPerPage; private String sortColumn; private ArrayList&lt;SelectItem&gt; itemsPerPageArray; private ArrayList&lt;SomeObject&gt; list; // data for table private HtmlDataScroller scroller; // constructors, getters, setters, and other stuff here public void updateItemsPerPage(ValueChangeEvent valueChangeEvent) { itemsPerPage = (Long) valueChangeEvent.getNewValue(); resetScrollerIndex(); } private void resetScrollerIndex() { if (scroller!=null &amp;&amp; scroller.isPaginator()) scroller.getUIData().setFirst(0); } // called in constructor private void constructItemsPerPageArray() { itemsPerPageArray = new ArrayList&lt;SelectItem&gt;(); itemsPerPageArray.add(new SelectItem(new Long(10), "10")); itemsPerPageArray.add(new SelectItem(new Long(50), "50")); itemsPerPageArray.add(new SelectItem(new Long(100), "100")); itemsPerPageArray.add(new SelectItem(new Long(0), "All")); } } </code></pre> <p>To sum up, when I select the "All" item from the <strong>h:selectOneMenu</strong>, I get the exception mentioned above. Hopefully, I've included an appropriate level of detail. Thanks!</p>
 

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