Component initialization ordering issue
Hi,
I'm noticing a strange behavior for the component initialization ordering on a page. I have a simple application with two pages which look like:
page1:
<jsp:root ..>
...
<ui:textField .../>
<ui:passwordField .../>
<ui:button .../>
...
</jsp:root >
page2:
<jsp:root ..>
...
<ui:staticText ... text="Something" />
...
</jsp:root >
In the backing bean of page1.jsp, I save the value entered in the textField1 in sessionBean1.userId by doing something like:
public String button1_action(){
getSessionBean1().setUserId((String)textField1.getText());
System.out.println("User added to session. User: "+getSessionBean1().getUserId());
return"page2";
}
In the backing bean of page2.jsp, I have a code like shown below to greet the user:
publicvoid prerender(){
String msg ="Welcome "+ getSessionBean1().getUserId();
System.out.println("Message: "+msg);
staticText1.setText(msg);
}
The problem is that the greeting message that gets displayed on the page2 is not what I set in the prerender() method above (rather it is the one I specify in the "text" attribute of "ui:staticText" element in page2.jsp). It gets updated only if I click some other link (or a button) that I may have on page2. However, if I do not set the "text" attribute on the "ui:staticText" element on the page2.jsp then I can correctly see whatever text I set in the prerender() method of page2.java.
This has sort of confused me on the ordering of component initialization on a page. The documentation of the prerender() of the backing bean says that prerender() gets executed just prior to rendering the page, so then why aren't my values getting reflected on the rendered page even though in the server logs I can see (by the adding a log stmt) that the "text" was updated?
Thanks.

