Note that there are some explanatory texts on larger screens.

plurals
  1. POJSF: setting a property in a wizard form with multiple submit actions
    primarykey
    data
    text
    <p>I have this scenario: in the first tab of a primefaces wizard component, I have some fields and a button. The button saves some data, does some business logic and, with the results, sets some properties of the form bean (which is in ViewScope) that are not related to a specific field of the form. I have checked that in the invoke application phase, the values are set properly.<br> In the second tab I have another button that has to do some business logic using the values set by the first one but, doing some debug, I noticed that the values, even if not related to any field of the form, are overwritten I think during the update model phase invoked when I click the second button. </p> <p>How can I avoid this? Is there a way to obtain the correct behaviour?<br> I looked around but I couldn't find any example of a wizard form with multiple submissions. Thanks for help!</p> <pre><code>&lt;p:wizard widgetVar="wiz" render="true" id="wizard" showNavBar="false"&gt; &lt;p:tab id="step0" title="Step0" step="0"&gt; &lt;!-- Some other fields--&gt; &lt;p:commandButton value="Save and do some business logic" action="#{formBean.save}" oncomplete="wiz.loadStep (wiz.cfg.steps [1], false)"&gt; &lt;/p:commandButton&gt; &lt;/p:tab&gt; &lt;p:tab id="step1" title="Step1" step="1"&gt; &lt;!-- Some other fields--&gt; &lt;p:commandButton value="Second button: use the previous informations" action="#{formBean.doSomething}" oncomplete="wiz.loadStep (wiz.cfg.steps [2], false)"&gt; &lt;/p:commandButton&gt; &lt;/p:tab&gt; &lt;/p:wizard&gt; </code></pre> <p><strong>Edit:</strong><br> To show an example I can say that my bean contains a business logic object. During the first submission, this object is being saved so the database (Mysql and Hibernate), assigns to it a progressive id.<br> During the second submission, when I try to read this id, the value is zero so, obviously, I get an error.</p> <p>Something like:</p> <pre><code>public class FormBean{ private BLObject object; // Constructor Getters and setters // Method executed during the first submission public void save(ActionEvent actionEvent) { //Save the object and set his id PersistanceClass.getInstance().save(object); } // Method executed during the second submission public void doSomethingWhitTheId(ActionEvent actionEvent) { //Access the id... id=0 returned int id = object.getId(); } } </code></pre>
    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.
    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