Search This Blog

Showing posts with label ProcessAction. Show all posts
Showing posts with label ProcessAction. Show all posts

Wednesday, July 24, 2013

Form re submission of/on Page Reload Errror

The property 'action-url-redirect' must be added to the liferay-portlet.xml file. This will not allow the form to be re submitted once the page is refreshed after a form submission is already done.




By default the property is false and thus the form resubmission occurs

Display error and success messages in liferay

Error Display Many times we need to display the errors messages or the success messages on the jsp pages.The way it is done is the following. Add the following the your implementation of processAction.
 //for Errors 
    com.liferay.portal.kernel.servlet.SessionErrors.add(portletRequest, "unique-error-key"); 
//for Messages 
    com.liferay.portal.kernel.servlet.SessionMessages.add(portletRequest, "unique-message-key"); 
or In Language_xx.properties add your custom message in this file like this
unique-message-key2="Success"

 TO display them in your jsp use this:

Tuesday, January 27, 2009

ProcessAction Method

ProcessAction() Method

The JSR-168 Specification defines a portlet container that manages portlets.Each portlet’s life cycle contain some specific methods as per JSR-168 namely init(),ProcessAction(),destroy() method etc. . The portlet developer can implement these methods to provide the desired functionality.Among all the life-cycle methods of a portlet one of the most important method is the ProcessAction() method.This ProcessAction() method is Called after the user submits changes to a jsr-168 compliant portlet. It is Intended to process input from a user Interaction.The user must interact with the portlet giving some or the other kind of data to it which must be processed by a portlet.This way we can say that the portlet processing is done in the ProcessAction() method.Even if one tries to maximize the size of the portlet window it calls the ProcessAction() method.

public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException
{
}

The processAction() method is called only by the ActionURL. The other URL i.e RenderURL doesnt invoke the processAction() method.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 request values are obtained from the actionURL in the following way

public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException
{
// get the values submitted with the form

String identity = request.getParameter("parameter1");
String color = request.getParameter("parameter2");

......
}

the way we set the render parameters for the render() method is

public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException
{

......

response.setRenderParameter("parameter1", value1);
response.setRenderParameter("parameter2", value2);
}

My Blog List