| |||||||||||||||||||||||||||||||||||
|
Find this tutorial in: /usr/local/resin/webapps/resin-doc/portlet/tutorial/basic-action
An action request is a request for the portlet to do something before it is rendered. An action request to a portlet invokes the processAction method before invoking the render method. This tutorial adds an HTML form to the hello world portlet. The HTML form allows the user to set the "identity" and "color". The submission of the form is an action, it is a request to do something.
An action URL is created with response.createActionURL(). The resulting url indicates to the portal that it should invoke the processAction() method in the portlet before invoking the render() method. A form that uses an action parameter must always use the POST method. The portal may encode some special parameters in the url, and the use of the GET method would overwrite those parameters.
When the form submit button is pressed, the action url is used. The action url indicates to the portal that it is an action request. Responding to the action request, the portal invokes the processAction() method before invoking the render() method. The resulting HTML demonstrates how the portal might add parameters to the url. The url that is in the action attribute contains the ____A= parameter. The parameter has been added to mark the requet as an action request.
The portlet's implentation of processAction() uses response.getParameter() to get the submitted form parameters.
There is an important distinction here - during processAction() the parameters are the parameters submitted from a form, during render() the parameters are render parameters and the parameters submitted from a form are no longer available.
If the portlet is invoked from an action url, all render parameters are reset. The implementation of the processAction must use response.setRenderParameter() to set render parameters for the susbsequent call to render().
|