datascroller: strange behaviour when using rendered attribut
gressho Mar 3, 2008 4:16 AMHello,
strange things happen when using the datascroller in a dataTable combined
with the rendered attribute. I'm using JBoss AS 4.2.2, JBoss Portal 2.6.4, RichFaces
3.1.4.SR1, Faceletes 1.1.14, JBoss Portletbridge 1.0.0.B1 and have the following code
(in the template is a surrounding a4j:portlet):
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.ajax4jsf.org/rich"> <ui:composition template="../../layout/template.xhtml"> <ui:define name="body"> <rich:panel> <h:form> <rich:dataTable id="adminList" width="100%" value="#{libraryManagement.allLibraries}" var="library" rows="15"> <f:facet name="footer"> <rich:datascroller align="center" for="adminList"/> </f:facet> <rich:column style="font-weight:bold"> <f:facet name="header"> <h:panelGroup rendered="#{libraryManagement.showLinks}"> <h:commandLink action="#{libraryManagement.createLibrary}" style="float:right"> <h:graphicImage value="/icons/16x16/actions/document-new.png" alt="#{message.headerCreateLibrary}" title="#{message.headerCreateLibrary}" style="border:0px; vertical-align:bottom;"/> </h:commandLink> <h:outputText value="#{message.library}" id="header"/> </h:panelGroup> </f:facet> <h:panelGroup rendered="#{libraryManagement.showLinks}" style="float:right"> <h:commandLink action="#{libraryManagement.loadLibrary}"> <h:graphicImage value="/icons/16x16/actions/document-open.png" alt="#{message.headerEditLibrary}" title="#{message.headerEditLibrary}" style="border:0px; vertical-align:bottom;"/> </h:commandLink> <h:commandLink action="#{libraryManagement.deleteLibrary}" onclick="return confirm('#{message.confirmDelete}')" style="margin-left:5px"> <h:graphicImage value="/icons/16x16/actions/edit-delete.png" alt="#{message.headerDeleteLibrary}" title="#{message.headerDeleteLibrary}" style="border:0px; vertical-align:bottom;"/> </h:commandLink> </h:panelGroup> <h:outputText value="#{library.title}"/> </rich:column> </rich:dataTable> </h:form> </rich:panel> </ui:define> </ui:composition> </div>
When the rendered attribute evaluates to "false" everything works very well. When
the rendered attribute evaluates to "true", the commandLinks show up on the
first page, when using navigational elements from datascroller they won't show up
never again, even when returning to the first page!
I decided to double the dataTable and move the rendered attribute to the dataTable
itself:
<div xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.ajax4jsf.org/rich"> <ui:composition template="../../layout/template.xhtml"> <ui:define name="body"> <rich:panel> <h:form> <rich:dataTable id="firstList" rendered="#{!libraryManagement.showLinks}" width="100%" value="#{libraryManagement.allLibraries}" var="library" rows="15"> <f:facet name="footer"> <rich:datascroller align="center" for="firstList"/> </f:facet> <rich:column style="font-weight:bold"> <f:facet name="header"> <h:outputText value="#{message.library}" id="header"/> </f:facet> <h:outputText value="#{library.title}"/> </rich:column> </rich:dataTable> <rich:dataTable id="secondList" rendered="#{libraryManagement.showLinks}" width="100%" value="#{libraryManagement.allLibraries}" var="library" rows="15"> <f:facet name="footer"> <rich:datascroller align="center" for="secondList"/> </f:facet> <rich:column style="font-weight:bold"> <f:facet name="header"> <h:panelGroup> <h:commandLink action="#{libraryManagement.createLibrary}" style="float:right"> <h:graphicImage value="/icons/16x16/actions/document-new.png" alt="#{message.headerCreateLibrary}" title="#{message.headerCreateLibrary}" style="border:0px; vertical-align:bottom;"/> </h:commandLink> <h:outputText value="#{message.library}" id="header"/> </h:panelGroup> </f:facet> <h:panelGroup style="float:right"> <h:commandLink action="#{libraryManagement.loadLibrary}"> <h:graphicImage value="/icons/16x16/actions/document-open.png" alt="#{message.headerEditLibrary}" title="#{message.headerEditLibrary}" style="border:0px; vertical-align:bottom;"/> </h:commandLink> <h:commandLink action="#{libraryManagement.deleteLibrary}" onclick="return confirm('#{message.confirmDelete}')" style="margin-left:5px"> <h:graphicImage value="/icons/16x16/actions/edit-delete.png" alt="#{message.headerDeleteLibrary}" title="#{message.headerDeleteLibrary}" style="border:0px; vertical-align:bottom;"/> </h:commandLink> </h:panelGroup> <h:outputText value="#{library.title}"/> </rich:column> </rich:dataTable> </h:form> </rich:panel> </ui:define> </ui:composition> </div>
The behaviour got even stranger: the first dataTable works well. When the rendered
attribute evaluates so the second dataTable is shown instead of the first, it will
be shown but is completely frozen. No navigation is possible!
Next thing I tried is perhaps more Facelets or JSTL: I dropped the rendered attribute
and surrounded each dataTable with an c:if from JSTL (which should work
according the facelets documentation): Both (!) dataTables were rendered and
worked very well. It's rather odd...
Best wishes
Werner