I am calling a page from another with a prerender view event in an f:metadata element.
If I navigate to page using <h:link>
it works and calls the listener method.
However if I navigate to the page using an outcome from the action method of a managed bean belonging to the calling page, the listener designated in the prerenderview doesn't get called (as it does if called by a link). It does navigate to the second page, just no listener call.
I would really prefer to call from the action method because I use it to do some work and place a variable in the session map for the called page to use. I'm not sure how to achieve the same thing using a link. The object can be rather large... kb not Mb but still not something I want to put in the request.
I've tried making the managed bean of the calling page request scoped and view scoped.
Is it not possible to get a prerenderview to fire if it is called from a managed bean outcome? As I said, I got it to work from a link.
<body>
<ui:define name="metadata">
<f:view>
<f:metadata>
<f:event type="preRenderView" listener="#{businessBean.init}" />
</f:metadata>
</f:view>
</ui:define>
<ui:composition template="#{navigationprops.soulard_2col_uprefs_template}">
ui:composition tag trim everything outside it, so facelets compiler doesn't have the chance to read the code. Instead, you should use ui:decorate, but remember f:metadata tag only works on the top level page, not inside the template client. For example:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:metadata>
<f:viewParam name="hotid"
value="#{hotelBooking.hotelId}"
converter="javax.faces.Long"/>
<f:event type="preRenderView" listener="#{hotelBooking.selectHotel}"/>
</f:metadata>
<ui:decorate template="template.xhtml">
<ui:define name="content">
<!-- ... -->
</ui:define>
</ui:decorate>
</ui:composition>
See This example for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With