/**
* Called by the portlet container to allow the portlet to process an action
* request. This method is called if the client request was originated by a
* URL created (by the portlet) with the
* <code>RenderResponse.createActionURL()</code> method.
* <p>
* The default implementation tries to dispatch to a method
* annotated with <code>@ProcessAction</name> that matches the action parameter
* value <code>ActionRequest.ACTION_NAME</code> or, if no
* such method is found throws a <code>PortletException</code>.<br>
* Note that the annotated methods needs to be public in order
* to be allowed to be called by <code>GenericPortlet</code>.
*/
public void processAction(ActionRequest request, ActionResponse response) throws PortletException,
java.io.IOException {
String action = request.getParameter(ActionRequest.ACTION_NAME);
try {
// check if action is cached
Method actionMethod = processActionHandlingMethodsMap.get(action);
if (actionMethod != null) {
actionMethod.invoke(this, request, response);
return;
}
} catch (Exception e) {
throw new PortletException(e);
}
// if no action processing method was found throw exc
throw new PortletException("processAction method not implemented");
}
1. in your subclass if you overrider processAction method, the container calls that method and code written in that method executes.
2. If you are not overriding this method container calls this method to handle Action Request coming to Portlet. When Action request comes to container, this method find the ACTION_NAME value in ActionRequest object and calls a method which has @ProcessAction annotation and name attribute value same as ACTION_NAME value.
Ex:
@ProcessAction(name = "registerUserAction")
public void registerUser(ActionRequest request,
ActionResponse response) throws PortletException, IOException {
...
}
Note:
public static final String ACTION_NAME = "javax.portlet.action";
No comments:
Post a Comment