Duplicate Form Submission in Liferay 

Liferay form submissions are handled in  processAction method. In this post, we will see “How to prevents duplicate form submission in Liferay?”

High Level Steps:

  • add  “<action-url-redirect>true</action-url-redirect>” in liferay-portlet.xml on above”instanceable” attribute. Default action-url-redirect value is false, set to “true” to enable redirection
  • On Leaving action phase, portlet enters into render phase by copying all action parameters also. When user clicks on reload button after form browser causes duplication form submission and explained process here:
    • Browser  sends action request
    • Action URL processed at Controller
    • Sends success code to browser
  • doView() method will be invoked with the same URL which is having actionURL parameters. In this case, request again processed second time.

Solution to prevent duplication form submission in Liferay for action request:

Approach 1:

  • Get the current URL
    • String redirectUrl = PortalUtil.getCurrentURL(renderRequest);
  • set the redirectUrl for action Request
    • <portlet:actionURL copyCurrentRenderParameters="false" name="addData" var="addDataUrl">
       <portlet:param name="redirectUrl" value="<%=PortalUtil.getCurrentURL(renderRequest) %>"/>
  • Invoke actionResponse.sendRedirect(redirectUrl) to redirect to home page.
  • view.jsp
<portlet:actionURL copyCurrentRenderParameters="false" name="processAddItem" var="addItem">
 <portlet:param name="redirectUrl" value="<%=PortalUtil.getCurrentURL(renderRequest) %>"/>
<form method="post" action="<%=processAddItem.toString() %>">
 <aui:input type="text" /> 
 <aui:input type="button"/> 

Approach 2:

Create Portlet URL for renderPhase to redirect:

 Create Portlet URL for render phase to redirectURL

String portletName= themeDisplay.getPortletDisplay().getPortletName();
 PortletURL portletURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest),portletName,themeDisplay.getLayout().getPlid(),
 portletURL.setParameter("id" String.valueOf(id));
 actionRequest.setAttribute(WebKeys.REDIRECT, portletURL.toString());
 // Here you can redirect to RedirectURL or Portlet URL 
 try {
 } catch (IOException e) {




Hope this helps….

2 thoughts on “Duplicate Form Submission in Liferay”
  1. After authentication, it sends back a totally signed PSBT to Wasabi Wallet,
    which in flip broadcasts it to the Bitcoin network, successfully completing the spending transaction.

Comments are closed.