jsfhtml-tabletrinidad

How to force a Trinidad table with rows set, to display the first page/ range?


The set up: A (Trinidad) JSF page with a few inputs and a couple buttons, one of which is "Search." The action of the search is to take the inputs and use them as search parameters for a call to the database, then displays these in a <tr:table> which is hidden until the backing bean returns with the search results. The table uses the rows attribute to break the data into ranges; we have this set to 10, and the search can return over 100 results if the user sets very loose parameters.

The scenario: The user has done a search and has paged through the table. The user changes the input parameters and clicks "Search" again.

Desired result: The new results shown in the table, with the table at PAGE ONE, ie. records 1 through 10.

Actual result: The new results shown in the table, with the table at whatever page number the user had been on previously.

My question: The <tr:table> does not have any getter/setter for the current page range, at least not that I could find in the documentation. Is there anything I can do in either the bean or the page, such that when new results are returned from DB, the table goes to the first page/ range?


Solution

  • my trinidad tables have bindings and I solved this issue by this:

    mytable.setFirst(0);
    

    mytable is declared as: org.apache.myfaces.trinidad.component.core.data.CoreTable

    But this should also work:

    ((CoreTable)FacesContext.getCurrentInstance().getViewRoot().findComponent("IdofyourTable")).setFirst(0);
    

    I am using trinidad 1.2.14