When changing languages from the language portlet, the user is redirected to the last URL. If the URL corresponds to an actionRequest, that action is triggered a second time.
I tried with the following simple code, with the classic theme, in liferay 6.1 GA2
view.jsp:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<portlet:actionURL name="myProcessAction" var="myProcessActionURL" />
<a href="<%= myProcessActionURL %>">my process action</a>
<form action="<%= myProcessActionURL %>" method="post">
<input type="submit" />
</form>
testportlet.java:
public class TestPortlet extends MVCPortlet {
public void myProcessAction(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException {
_log.info("processing action");
}
private static Log _log = LogFactoryUtil.getLog("TestPortlet");
}
I add my test portlet to a new page, as well as the language portlet.
Submit the form -> log shows “processing action”
switch languages -> log shows “processing action” again !
Best regards,
Alain
You can specify where the page is redirected by including a “redirect” parameter. For example:
The
MVCPortletclass will automatically see this parameter and redirect to it if the request is successful.