Action Phase Example

In Action Phase, processAction(…) method is invoked.

package com.test;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
 * Portlet implementation class ActionPortlet
public class ActionPortlet extends GenericPortlet {
    public void init() {
        viewJSP = getInitParameter("view-jsp");
    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, PortletException {
        // Pass information from Action Phase to Render Phase
    public void doView(
            RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {
        String state = renderRequest.getParameter("state");
        renderRequest.setAttribute("state", state);
        include(viewJSP, renderRequest, renderResponse);
    protected void include(
            String path, RenderRequest renderRequest,
            RenderResponse renderResponse)
        throws IOException, PortletException {
        PortletRequestDispatcher portletRequestDispatcher =
        if (portletRequestDispatcher == null) {
            _log.error(path + " is not a valid include");
        else {
            portletRequestDispatcher.include(renderRequest, renderResponse);
    protected String viewJSP;
    private static Log _log = LogFactoryUtil.getLog(ActionPortlet.class);


<%@ taglib uri="" prefix="portlet" %>
<%@ taglib uri="" prefix="aui" %>
<portlet:defineObjects />
<portlet:actionURL var="testAction" />
<aui:form action="<%= testAction %>" method="post">
    <aui:input label="Input" name="greeting" type="text" />
    <aui:button type="submit" />
State: ${state}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License