I have a test.xhtml page where I defines an event
<f:metadata>
<f:event type="preRenderView" listener="bean.setUrl()"/>
</f:metadata>
page also has a insert tag in it.
<ui:insert name="melcontent">
<ui:include id="contentscreen" src="bean.url"/>
</ui:insert>
Now problem is that i want to set this include src page src="/page/somepage.xhtml" dynamically in prerender event some where in backing bean and wants to load in include tag from that backing bean but before prerender calls listener, include had been already executed even before prerender. can any one suggest a way to achieve this. thanks in advance.
The tag ui:include is a taghandler, which means it runs in view build time instead of view render time. So the preRenderView happens later.
Build time tags - they are used to change the building of a component tree. They will not make any change during the render time.
Render Time - when the view is rendered to produce the HTML. It happens later.
If you really need to do it using the ui:include, you could add a list of includes wrapped by ui:fragment with a rendered attribute, since ui:fragment rendered attribute is gonna be evaluated during render time. Like:
<h:panelGroup id="panel">
<ui:fragment rendered="#{bean.conditionFirstFile}">
<ui:include src="first.xhtml"/>
</ui:fragment>
<ui:fragment rendered="#{bean.conditionSecond}>
<ui:include src="second.xhtml"/>
</ui:fragment>
...
</h:panelGroup>