Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Franklin Phan
Method annotated with @ProcessAction not getting triggered
July 21, 2009 12:48 AM
Answer

Franklin Phan

Rank: Regular Member

Posts: 137

Join Date: March 10, 2009

Recent Posts

The following method (in the default JSPPortlet class created by the plugins SDK) is not firing when JSP form is submitted:
1@ProcessAction([b]name="testAction"[/b])
2void testActionURL(ActionRequest request, ActionResponse response)
3        throws PortletException, IOException {
4    String junk = request.getParameter("junk");
5}


The form in the JSP (from view.jsp fragment):
1<form id="<portlet:namespace/>test" action='<portlet:actionURL [b]name="testAction"[/b]/>' [b]method="post"[/b]>
2  <input type="hidden" name="junk" value="abc" />
3  <input type="submit" value="Submit" />
4</form>


According to the Portlet API for the processAction in GenericPortlet class:
The default implementation tries to dispatch to a method annotated with @ProcessAction that matches the action parameter value ActionRequest.ACTION_NAME or, if no such method is found throws a PortletException.


According to PLT.5.4.5.1 of the Portlet 2.0 Specification:
For a received action the processAction method in the GenericPortlet class tries to
dispatch to methods annotated with the tag @ProcessAction(name=<action name>)...


So is this a Liferay bug, or a GenericPortlet bug?

What am I missing?
Oliver Bayer
RE: Method annotated with @ProcessAction not getting triggered
July 21, 2009 12:59 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 881

Join Date: February 18, 2009

Recent Posts

Hi Franklin,

I'm getting the annotations to work in Liferay 5.2.3 and Liferay trunk by the following steps:

1. remove the default method public void processAction(...) form portlet class
2. change the annotations method to public

1[b]public[/b] void testActionURL(ActionRequest request, ActionResponse response)

The actionURL form your jsp seems to be allright.

HTH
Franklin Phan
RE: Method annotated with @ProcessAction not getting triggered
July 21, 2009 1:28 AM
Answer

Franklin Phan

Rank: Regular Member

Posts: 137

Join Date: March 10, 2009

Recent Posts

Thanks. That works. So the bloody Portlet 2.0 Spec is wrong! PLT.5.4.5.1 Action Dispatching reads:
For a received action the processAction method in the GenericPortlet class tries to
dispatch to methods annotated with the tag @ProcessAction(name=<action name>) . . . and
following signature:
1     void <methodname> (ActionRequest, ActionResponse) throws
2             PortletException, java.io.IOException;
Oliver Bayer
RE: Method annotated with @ProcessAction not getting triggered
July 21, 2009 1:58 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 881

Join Date: February 18, 2009

Recent Posts

Hi,

great to hear that you get it to work. I'm searching for this simple solution some time till I found the follwing URL: [url=http://www.bluesunrise.com/portlet-api/javax/portlet/GenericPortlet.html#processAction(javax.portlet.ActionRequest,%20javax.portlet.ActionResponse)]Generic Portlet Spec

There you will find this hint:
Note that the annotated methods needs to be public in order to be allowed to be called by GenericPortlet.


Greets Oli
Franklin Phan
RE: Method annotated with @ProcessAction not getting triggered
July 28, 2009 11:26 AM
Answer

Franklin Phan

Rank: Regular Member

Posts: 137

Join Date: March 10, 2009

Recent Posts

I thought I read that somewhere. I kept searching the spec for it. They need to make the API and the spec consistent with each other.
BTW, I've been discovering ambiguities, poor grammar, and gross errors in the spec. After years in the making, one would think that the spec would be better than that.