Note that there are some explanatory texts on larger screens.

plurals
  1. POViewscoped bean doesnt retain it's state when returning to the same view?
    primarykey
    data
    text
    <p>Im currently testing on JSF Bean that make use of ViewScope</p> <p>I notice this behaviour.</p> <p>When having this button :</p> <pre><code>&lt;p:commandButton value="Submit Data to Server" ajax="false" update="debugPanel" /&gt; </code></pre> <p>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. </p> <p>But when i add modify my button into this :</p> <pre><code>&lt;p:commandButton value="Submit Data to Server" ajax="false" update="debugPanel" action="viewScope2.xhtml?faces-redirect=false"/&gt; </code></pre> <p>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> <pre><code>&lt;p:commandButton value="Submit Data to Server" ajax="false" update="debugPanel" action="viewScope2.xhtml"/&gt; </code></pre> <p>But still, the postconstruct method gets called for every submission, which is not desireable.</p> <p>Is it possible to have this idealism :</p> <blockquote> <p>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.</p> </blockquote> <p>Please share your opinions !</p> <p>Thank you .....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload