reRender and rendered issue or feature?
antibrumm Aug 11, 2009 10:27 AMHello all.
I'm kinda new to Richfaces with using it since around 3 month and i ran into a problem now where i'm not getting what happens.
I find it quite strange that the rendered attributes are evaluated even if the component is outside of the rerender regions. Is that normal behavior because of a diffrent phase in the jsf lifecycle or do i something wrong in my code?
(The basis is a straight forward Seam application created with the Eclipse wizard)
Simple Helper object
@Name("testHelper") @Scope(ScopeType.PAGE) public class TestHelper implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Logger Log log; public void action(String action) { log.info("action " + action); } public String getText(String text) { log.info("getText: " + text); return text; } }
I've created this page for a test.
<ui:define name="body"> <rich:panel id="panel1"> <a:form> <h:outputText value="#{testHelper.getText('text1')}" /> <br /> <a:commandButton action="#{testHelper.action('button1')}" value="Action on Panel1" reRender="panel1" /> <a:commandButton action="#{testHelper.action('button2')}" value="Action on Panel2" reRender="panel2" /> </a:form> </rich:panel> <rich:panel id="panel2"> <a:form> <h:outputText value="#{testHelper.getText('text2')}" /> <br /> <a:commandButton action="#{testHelper.action('button3')}" value="Action on Panel2" reRender="panel2" /> <a:commandButton action="#{testHelper.action('button4')}" value="Action on Panel1" reRender="panel1" /> </a:form> </rich:panel> </ui:define>
As expected if i press "Action on Panel1" only the panel1 if rerendered and if get the output:
15:21:17,518 INFO [TestHelper] action button1
15:21:17,549 INFO [TestHelper] getText: text1
Then i created another page with the rendered attribute on the outputtext:
<ui:define name="body"> <rich:panel id="panel1"> <a:form> <h:outputText value="#{testHelper.getText('text1')}" rendered="#{testHelper.getText('testText') == 'testText'}" /> <br /> <a:commandButton action="#{testHelper.action('button1')}" value="Action on Panel1" reRender="panel1" /> <a:commandButton action="#{testHelper.action('button2')}" value="Action on Panel2" reRender="panel2" /> </a:form> </rich:panel> <rich:panel id="panel2"> <a:form> <h:outputText value="#{testHelper.getText('text2')}" /> <br /> <a:commandButton action="#{testHelper.action('button3')}" value="Action on Panel2" reRender="panel2" /> <a:commandButton action="#{testHelper.action('button4')}" value="Action on Panel1" reRender="panel1" /> </a:form> </rich:panel> </ui:define>
And here suddenly i get outputs from both rendered attributes with clicking on "Action on Panel1"...
16:24:48,306 INFO [TestHelper] getText: testText1
16:24:48,321 INFO [TestHelper] getText: testText1
16:24:48,321 INFO [TestHelper] getText: testText1
16:24:48,337 INFO [TestHelper] action button1
16:24:48,353 INFO [TestHelper] getText: testText1
16:24:48,353 INFO [TestHelper] getText: testText1
16:24:48,353 INFO [TestHelper] getText: testText1
16:24:48,368 INFO [TestHelper] getText: testText1
16:24:48,368 INFO [TestHelper] getText: testText1
16:24:48,368 INFO [TestHelper] getText: text1
16:24:48,384 INFO [TestHelper] getText: testText2
If someone could explain me why this happens would be perfect :)
Greetings
Anti