Portlet: form that submits to either an action or directly a render phase?

826 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

From the lack of answers there does not seem to be a way to solve it with portal ways, but I stumbled over How do you overcome the html form nesting limitation? and thanks shovavnik, it looks like at least at some point html 5 will be the rescue.