I added postAddtoView event listener to below component. I was expecting the orderView.populateForm listener method is being called once during creation of the initial view (https://javaserverfaces.java.net/nonav/docs/2.2/javadocs/javax/faces/event/PostAddToViewEvent.html ). For any postback call where view is restored I do not expect a new component instance is added to view. Hence no event to fire.
However, event listener method is being called for each postback call.
<h:form id="orderForm">
<p:panelGrid id="attributePanel" columns="#{orderView.numberOfGridColumns}">
<f:event type="postAddToView" listener="#{orderView.populateForm}" />
</p:panelGrid>
<p:commandButton ajax="true" value="Create" process="@form" update="@form"/>
</h:form>
OrderView is a view scoped CDI bean. As far as I understand view scoped beans are stored in the partial view state and by default partial view state saving is enabled. (BalusC gives a nice explanation here about the issue Should PARTIAL_STATE_SAVING be set to false?) To see it has an effect, I disabled/enabled partial state saving. It did not help.
Thanks in advance. PS: I am running on Mojarra 2.2.12/ Glassfish 4.1