I am new to using omnifaces. From the little I gathered, the postInvokeAction is a better choice to use when handling objects in flashscope rather than the jsf preRenderView event. But what I noticed is that the listener method is been called twice! I felt that the preInvokeAction is analogous to the before phase listener and the postInvokeAction analogous to the after phase listener equivalent of the PhaseID.INVOKE_APPLICATION and as such should be called only once for the corresponding event. Is this correct? Kindly explain to me please.
I currently run on Mojarra 2.1.17 and Omnifaces 1.3.
Thank you in anticipation for your replies!
layout1.html
<h:body>
<p style="color: blue; font-size: 12pt;">1. This is the main content of the file.</p>
<ui:insert name="body_contents"/>
<p style="color: blue; font-size: 12pt;">This is the the remaining part of the document... in layout1</p>
</h:body>
samplepage2.html
<h:body>
<f:view>
<f:metadata>
<f:viewParam name="dummy_var" value="#{sampletest.val_test}"/>
<f:event type="postInvokeAction" listener="#{sampletest.frompostinvokeaction}" />
<f:event type="preRenderView" listener="#{sampletest.fromprerenderview}" />
</f:metadata>
</f:view>
<ui:composition template='/layout1.html'>
<ui:define name="title_on_head">
<style type="text/css">
.pkssd{
min-width: 340px; min-height: 30px; background: appworkspace; color: blue; font-size: 11pt; font-style: italic;
}
</style>
</ui:define>
<ui:define name="body_contents">
<p class="pkssd">This is the active content...</p>
</ui:define>
</ui:composition>
</h:body>
SampleTest.java
@ManagedBean(name="sampletest")
@ViewScoped
public class SampleTest {
private String val_test; public void frompostinvokeaction(){
System.out.println("frompostinvokeaction: val_test: " + val_test); }
public void fromprerenderview(ComponentSystemEvent cse){
System.out.println("fromprerenderview : val_test: " + val_test);
}
}