Im currently testing on JSF Bean that make use of ViewScope
I notice this behaviour.
When having this button :
<p:commandButton value="Submit Data to Server"
ajax="false" update="debugPanel" />
I can see the postconstruct happens only once, and the submission triggered by this button doest trigger postconstruct, which is correct, since it's returning to the same view.
But when i add modify my button into this :
<p:commandButton value="Submit Data to Server"
ajax="false" update="debugPanel"
action="viewScope2.xhtml?faces-redirect=false"/>
I can see that the postconstruct method gets called for every submission, which means the bean doesnt retain it's state, although it's actualy returning to the same view. I thought this is because of the redirectin, so i omitted it, and the button becomes something like this :
<p:commandButton value="Submit Data to Server"
ajax="false" update="debugPanel"
action="viewScope2.xhtml"/>
But still, the postconstruct method gets called for every submission, which is not desireable.
Is it possible to have this idealism :
No matter whether it's explicitly or implicily defined (via attribute or via return "myview.xhtml" in action method) , whether it's using redirect or not, the viewscoped bean will always retain it's state when returning to the same view.
Please share your opinions !
Thank you .....