myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From LucaG...@gmx.de
Subject Confusing behavior with generated id's in <tr:table>
Date Tue, 07 Jul 2009 14:05:07 GMT
Hi,

today i seeing some confusing behavior with the <tr:table> component. If i "reset" the
pagination with the setFirst(0) method of the table component, the table will be rerendered
correct and the first page is shown. But if you call the setFirst() method from another page
then the first the generated "row id's" start with 20 instead of 0. (xxx:yyy:20:zzz)

Thats looks not so critical on the first sight ... But i use the id/index  to toggle some
detail informations of an row/item via JavaScript onmouseover.
This works nice, as long i don't call the setFirst() method to jump to the first page. After
that i have no chance to match the index with the generated id because the index and the generated
id's are different. (the generated id's start with 20 instead 0)

Another bit confusing thing is that "varStatus.index" get counted over the whole result. But
the generated "row id's" contains only numbers for one page (from 0 to rows-1) so you must
additionally store the start index of your current page to calculate the "right" index that
will match with an generated id.

Is call setFirst() not enough to reset the pagination of an <tr:table>?
Or this is an Bug and i should open an issue in the jira?


Cheers Luca
Sorry for the double mail :(


Here is an simple example (I can provide this as eclipse project, too):

<tr:commandButton id="reset"
                  partialSubmit="true"
                  action="#{trinidadTableHandler.reset}"
                  text="reset paging"/>
                           
          
<tr:table id="listTable"
       binding="#{trinidadTableHandler.dataTable}"
       rows="#{trinidadTableHandler.rowsPerPage}"
       rangeChangeListener="#{trinidadTableHandler.pageChangedListener}"
       varStatus="status"
       partialTriggers="::reset"
       var="item" value="#{trinidadTableHandler.searchResult}">
                     
       <tr:column>
          <h:graphicImage url="/pages/images/question-balloon.png"
             onmouseover="toggleComponent('form:listTable:#{status.index - trinidadTableHandler.currentStartIndex}:layer');"
             onmouseout="toggleComponent('form:listTable:#{status.index - trinidadTableHandler.currentStartIndex}:layer');"/>
                   
           <tr:panelGroupLayout id="layer" inlineStyle="display:none position:absolute;">
               <tr:outputText value="Detail: #{item.detailText}"/>
           </tr:panelGroupLayout>
       </tr:column>
               
       <tr:column>
          <h:outputText value="#{item.text}"/>
       </tr:column>         
</tr:table>



public class TrinidadTableHandler
{

    private static final int ROWS_PER_PAGE = 20;
   
    private CoreTable dataTable;
    private int currentStartIndex = 0;
    private int currentEndIndex   = ROWS_PER_PAGE -1;
   
    private List<Item> searchResult;
   

    public TrinidadTableHandler() { }

   
    public String reset()
    {
        setCurrentStartIndex(0);
        setCurrentEndIndex(ROWS_PER_PAGE - 1);
        getDataTable().setFirst(0);
        return "success";
    }
   
    public void pageChangedListener(RangeChangeEvent rce)
    {
        setCurrentStartIndex(rce.getNewStart());
        setCurrentEndIndex(rce.getNewEnd());
    }
   
    public List<Item> getSearchResult()
    {
        if(null == searchResult)
        {
            searchResult = new ArrayList<Item>();
            for(int i=0;i<500;i++)
            {
                searchResult.add(new Item("Item_" + i, "Detail_" + i));
            }
        }
        return searchResult;
    }

    ...
}
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

Mime
View raw message