Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring MVC preview implementation
    primarykey
    data
    text
    <p>I have following task: implement "preview" functionality using Spring MVC. And it will be good to know the best way to implement it:</p> <p>It is straight forward task to 1. Populate new form and save this form in the DB: In order to do this on jsp page we have a spring form, we pass this from to controller and save this from. 2. Edit some form data: So, In order to do that we pass object id to controller, controller reads necessare data from DB -> User has possibility to edit this and save again in the DB.</p> <p>But It looks like there is no straight forward mechanism for implementation "preview" functionality.</p> <p>As example: We have a form and user has possibility to add necessary values to the form and then we should display how this data (that user added) will look like on the separate screen (we perform some data manipulation and diplaying how this data will look like for different tool).</p> <p>In the code we have following situation:</p> <ol> <li><p>In the controller in order to render preview we pass our model:</p> <p>@RequestMapping(value="/preview", method = RequestMethod.POST) public String preview(@ModelAttribute("form") SomeForm form){ return "preview"; }</p></li> </ol> <p><br>and on the preview.jsp we have possibility to render it in the appropriate way:<br></p> <pre><code> &lt;div class="preview"&gt; &lt;div id="1"&gt;${form.field1}&lt;/div&gt; &lt;div id="2"&gt;${form.field2}&lt;/div&gt; &lt;/div&gt; </code></pre> <p>And on this jsp page we don't have a form. In order to get back to edit page we need to pass a form object because our controller requires it: <br></p> <pre><code>@RequestMapping(value = "/admin/save", method = RequestMethod.POST) public String save(@ModelAttribute("form") SomeForm form ){ </code></pre> <p>And the main problem pass back this form to the original jsp page.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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