Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: prevent back and refresh button to avoid form resubmission (Liferay 7)
we are doing payment related functionality,so after the payment completed if user can click on back button or refresh the transaction deduct twice , so how can we avoid to user for form submission . we are using Liferay7
Hi ,
After action you can create a render url and redirect to it or create a render url and send it to mvcrender command
After action you can create a render url and redirect to it or create a render url and send it to mvcrender command
Hello Mohammed,
Now , I am doing like below code , after form submission we calling action method , in action method wen storing data in DB and after that we rendering to next page their we will showing him sucess message like "Account created successfully"
demo code as like below,
public void createUser(ActionRequest req, ActionResponse res ){
// inserting logic here
actionResponse.setRenderParameter("mvcPath","/pages/result.jsp");
}
but , here issue is like on result.jsp , when he refreshing , or clicking back button then our createUser method again executing
Thanks & Regards,
Pradip
Now , I am doing like below code , after form submission we calling action method , in action method wen storing data in DB and after that we rendering to next page their we will showing him sucess message like "Account created successfully"
demo code as like below,
public void createUser(ActionRequest req, ActionResponse res ){
// inserting logic here
actionResponse.setRenderParameter("mvcPath","/pages/result.jsp");
}
but , here issue is like on result.jsp , when he refreshing , or clicking back button then our createUser method again executing
Thanks & Regards,
Pradip
Hi ,
Instead setting the render parameter you create a render url and send redirect
PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, themeDisplay.getPortletDisplay().getId(), PortletRequest.RENDER_PHASE);
portletURL.setPortletMode(LiferayPortletMode.VIEW);
portletURL.setParameter("jspPage", "/pages/result.jsp");
actionResponse.sendRedirect(portletURL.toString());
Instead setting the render parameter you create a render url and send redirect
PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, themeDisplay.getPortletDisplay().getId(), PortletRequest.RENDER_PHASE);
portletURL.setPortletMode(LiferayPortletMode.VIEW);
portletURL.setParameter("jspPage", "/pages/result.jsp");
actionResponse.sendRedirect(portletURL.toString());
Hi,
we can use "com.liferay.portlet.action-url-redirect=true" property for avoiding re submission of form.
we can use "com.liferay.portlet.action-url-redirect=true" property for avoiding re submission of form.
This i think its not supported from Liferay 7 onwards, in 6.2 it was used for avoiding re-submission.
Mohammed yasin:
This i think its not supported from Liferay 7 onwards, in 6.2 it was used for avoiding re-submission.
I'm assuming you mean com.liferay.portlet.action-url-redirect?
According to the documentation (https://portal.liferay.dev/docs/7-2/reference/-/knowledge_base/r/portlet-descriptor-to-osgi-service-property-map) it's still there, which points to it being supported - or a bug if it doesn't work.
In fact, the notation that Santosh B Biradar used, is the OSGi property notation (available since 7.0), not the 6.2 xml/dtd notation.
Hi Olaf Kock,
Your right "com.liferay.portlet.action-url-redirect=true" is working fine .Thanks for correcting
Your right "com.liferay.portlet.action-url-redirect=true" is working fine .Thanks for correcting
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™