rendered attribut not working
me_lucky_charms Aug 21, 2009 1:01 PMGood afternoon all.
I am writing a simple search form that when initially hit, I would like the results table hidden. When the form is submitted and passes validation, I would like the results table to be displayed.
I am having a problem with the rendered attribute not working (never rendering, even when the result of the call is 'true') when presented with a dynamic value. Here is my xhtml document:
<a4j:form> <a4j:region> <h:panelGrid border="0" cellspacing="4" columns="4"> <h:outputText value="Report Type"></h:outputText> <h:outputText value="Start Date"></h:outputText> <h:outputText value="End Date"></h:outputText> <h:outputText value=""></h:outputText> <h:selectOneMenu value="#{reportsForm.reportType}"> <f:selectItems value="#{reportsForm.reportTypeList}"></f:selectItems> </h:selectOneMenu> <rich:calendar value="#{reportsForm.startDate}" datePattern="MM/dd/yyyy hh:mm a" /> <rich:calendar value="#{reportsForm.endDate}" datePattern="MM/dd/yyyy hh:mm a" /> <a4j:commandButton action="#{reportsForm.generate}" value="Run Report" reRender="reportResults"/> </h:panelGrid> </a4j:region> <a4j:region> <rich:dataTable id="reportResults" value="#{reportsForm.results.records}" var="r" rendered="#{reportsForm.renderResults}"> <f:facet name="header"> <h:outputText value="Results" /> </f:facet> <rich:column> <f:facet name="header"><h:outputText value="NAME" /></f:facet> <h:outputText value="#{r.fullName}"/> </rich:column> </rich:dataTable> </a4j:region> </a4j:form>
And here is the relevant code from the reportsForm request scoped managed bean:
... public String generate() throws Exception { List<TransactionReportsView> records = ((WFAdminEntityDAO) EntityDAOFactory.getInstance()).queryReport(this); results = new Report(records); submitted = true; return null; } ... public boolean isRenderResults() { return submitted; } ...
Now when I first hit the page, submitted is false and the table is not displayed. But when I hit the button, the table does not display even though the search did get processed and submitted was set to true.
I added a breakpoint to the isRenderResults() method and on the initial page rendering the method returns false, as expected. And when I perform the search, the method returns true, but the table will not render. Now if I modify the isRenderResults() to just return true or just hard-code true into the rendered attribute, the table is always rendered.
Now, I am noticing that the isRenderResults() method is getting called several times per request. When I first started out (I am very new to all of this, BTW) that method would be getting called once for each phase up to 5 and several times during phase 6. So I added the regions and now the method only gets called during phase 6, although still several times. I found a page saying this is normal (http://forum.springsource.org/showthread.php?t=69719) but I'm wondering if it is somehow to blame. Although I have confirmed that each time it is called during the search, it is returning true and still not rendering the table.
Thanks in advance for any help.