jsf 2 - ui:include value is evaluated before preRenderView -
page1.xhtml
<h:body> <h:link outcome="page2.xhtml> <f:param name="id" value="1"/> </hlink> </h:body>
page2.xhtml
<h:body> <f:metadata> <f:event type="prerenderview" listener="#{mybean.init}"/> </f:metadata> <ui:include src="#{mybean.mystring}"/> </h:body>
mybean.java
public void init(componentsystemevent e){ map<string,string> params = facescontext.getexternalcontext().getrequestparametermap(); string myid = params.get("id"); int id = integer.parseinteger(myid); if(id==1) setmystring = "mypage.xhtml"; }
while navigating page1.xhtml page2.xhtml sending id parameter according id display page
the problem page cannot find
i printing in console what's happening found is evaluating getmystring() before going prerenderview init why happening this
i tried post construct returned error in resource injection of managedbean
that's classic view build time vs view render time problem: <ui:include>
tag handler that's evaluated @ view build time, while <f:event type="prerenderview">
naturally called when view rendered. guess, latter event happens after former, while expect otherwise. still, when former tag requests evaluate attribute, it's null
, or isn't there yet.
read classic jstl in jsf2 facelets... makes sense? better grasp @ what's relationship between these 2 phases of jsf lifecycle.
Comments
Post a Comment