Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have solve a similar (not same) scenario with an MVC Interceptor.</p> <p>For me the problem is, that I have Forms. If the user enter something in the form, and the request is accepted, then he normally get REDIRECTED to the according show page. (REST Pattern). But there are some forms that should behave different, if the from is "invoked" from a special page.</p> <p>Example: So if a user goes to Page "A", from there to Page "F" with the form, enters the value and submits, then he get (after the according action is executed in the server) redirected to PAGE "S". But if the user starts with Page "B", then go to the Form Page "F", submits the form, then he should be redirected to "B".</p> <p>It works this way: I have an special request parameter <code>RETURN_ACTIVATE</code> this parameter contains an URL. The MVC Interceptor detect if the current request has this parameter. (For easy use, the MVC interceptor also check if <code>RETURN_ACTIVATE</code> exits, but is blank, then it replaces its value with the HTTP referer). </p> <ul> <li>Now if the MVC Interceptor detect the current request has this <code>RETURN_ACTIVATE</code> parameter and the web controller response is an redirect, then it replace the redirect url with that one from the <code>RETURN_ACTIVATE</code> parameter</li> <li>But if the web controller response is a normal form view, then the Interceptor adds only the a value also named <code>RETURN_ACTIVATE</code> to the model. Its value is the value from the <code>RETURN_ACTIVATE</code> parameter.</li> </ul> <p>In every of my forms I add a hidden vparameter named <code>RETURN_ACTIVATE</code> if the model contains the value <code>RETURN_ACTIVATE</code> (the value of the hidden paramter is of course the value from the model). </p> <p>So at the end the only thing I need to do to get the complete stuff running, is adding a parameter with no value to the link in Page "B" that the user use to get to page "F". <code>&lt;a href="f?RETURN_ACTIVATE"&gt;formPage&lt;/a&gt;</code> Then the MVC Interceptor add the parameter with the referer URL to the model, because the Controller returns the View for the Form. The JSP add the hidden value <code>&lt;input type="hidden" name="RETURN_ACTIVATE" value="b"/&gt;</code> to the form. When the user submits the form, and the controller responde with an redirect to "s", then the MVC Intercepter change "c" to "b".</p> <p>So my solution is a bit more complicated because the use case is more complicated, but I hope it gives you some ideas.</p>
 

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