In a Portlet project (which uses spring 3.1) Consider the following form:
<portlet:actionURL var="actionUrl" />
<portlet:renderURL var="renderUrl" />
<form action="${actionUrl}" method="POST">
<!-- A number of checkboxes -->
With selected do:
<button type="submit" name="stuff" value="action">Action</button>
<button type="submit" name="stuff" value="render" onclick="jQuery(this).closest('form').prop('action', ${fn:escapeXml(json:json_encode(renderUrl))})">Render</button>
</form>
As you can see there is a form with two submit buttons. Depending on the button pressed I either want to go to an action phase or skip the action phase and directly go to the render phase.
The code above works and has the effect that I desire, but it is not pretty. It's more like a hack, exchanging the action attribute of the form using javascript.
Is there a JSR-286 compliant way to do this server side? One idea I head was to just do the stuff I'd normally do in the render phase (put a ModelAndView object together) in the action phase, store the ModelAndView in a session, pop it from the session in the render method and return it. But that still feels like an unprettry hack. Any pretty solutions for that?