lisak
lisak

Reputation: 21961

Spring portlet @ActionMapping usage

could please anybody explain, how POST request should be mapped properly ? it is not clear from API documentation.

value should be assigned with the value of the action parameter javax.portlet.action

@ActionMapping(value = "addDocOrder")
public void addDocOrder(@ModelAttribute("order").......

AND next we have "params" (JAVADOC: The parameters of the mapped request, narrowing the primary mapping.)

@ActionMapping(params = "action=addDocOrder")
public void addDocOrder(@ModelAttribute("order").......

JAVADOC for value() parameter of annotation: The name of the action, according to the Portlet 2.0 "javax.portlet.action" parameter. If not specified, the method will be used as default handler: i.e. for action requests where no specific action mapping was found. Note that all such annotated action methods only apply within the @RequestMapping constraints of the containing handler class.

I absolutely don't get what is the point of the existence of the "value" annotation parameter. it has afaik no sense in being there ...it is meant to be the primary mapping, params the secondary one, but {params = "action=addOrder"} makes "value" redundant.

PLEASE: Take a look at this issue which is also relevant https://stackoverflow.com/questions/4782971/handling-ajax-requests-with-spring-portlet

Upvotes: 1

Views: 13371

Answers (2)

Eric
Eric

Reputation: 462

I agree with your assessment as well. The only real advantage I can see when reading the spec is that some special handling in the tag was added. Apparently these two are equivalent:

<portlet:actionURL>
  <portlet:param name="javax.portlet.action" value="addDocOrder"/>
</portlet:actionURL>

<portlet:actionURL name="addDocOrder" />

That is from "PLT.26.2 actionURL Tag" in the spec.

Upvotes: 3

Eric
Eric

Reputation: 462

javax.portlet.action is the name of the parameter that value() is mapped to. So for a mapping like:

@ActionMapping(value = "addDocOrder")
public void addDocOrder(@ModelAttribute("order").......

Your request should URL should be built like:

<portlet:actionURL>
  <portlet:param name="javax.portlet.action" value="addDocOrder"/>
</portlet:actionURL>

Upvotes: 1

Related Questions