Passing information from Action phase to Render phase in Liferay

Some times we want to pass parameters from action phase to render phase(jsp page). This can be achieved by two ways in liferay.

The action parameters set for action URL will be available in action phase. These parameters can be sent to render phase or JSP page by following method.

Each action parameter needs to be forwarded to render phase by using actionResponse.setRenderParameter() method. For example, using below method we can redirect to another jsp page once the action phase is executed by setting “parameter-name” as “mvcPath” and “parameter-value” to the jsp path, which needs to be rendered.

actionResponse.setRenderParameter("parameter-name", "parameter-value");

If we are using Liferay MVC Portlet implementation, then we can make all these action parameters available to render phase by setting the following attribute in Portlet.xml file.


These parameters will be available even if page is refreshed because of other portlet actions.

Second way of passing information from action phase to render phase is by using session. Liferay provides a helper class “SessionMessages” and tag libraries to show the messages in jsp page.

We can use SessionMessages to add the messages as shown below:

 SessionMessages.add(actionRequest, "success");

To access these values from jsp page, we can use tag library as shown below:

<portlet:defineObjects />

<liferay-ui:success key="success" message="successful!"/>

Also for error messages, we can use SessionErrors class and tag as shown below:

SessionErrors.add(actionRequest, "error");

//To retrieve in JSP:
<liferay-ui:error key="error" message="Sorry, Error occurred!!" />


Check out all Liferay related posts.