I have made a portlet in Liferay which displays a form. I would like to process the form data after submit, but the data "disappears" somewhere.
This is my form code in jsp:
<portlet:actionURL windowState="normal" var="filterURL">
</portlet:actionURL>
<form action="<portlet:actionURL />" method="post">
Industry: <input type="text" name="<portlet:namespace />industry" value="<%= industryFilter %>"/>
<input type="submit" value="Filter" />
</form>
The data should be passed to my portlet class, but it won't. This is my class code:
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {
String industryFilter = actionRequest.getParameter("industry");
if(industryFilter == null) {
industryFilter = "no-param";
}
actionResponse.setRenderParameter("industry", industryFilter);
super.processAction(actionRequest, actionResponse);
}
This class is intended to pass the data back to the jsp. The setRenderParameter()
method works fine, as in jsp I can read the value using request.getParameter("industry");
However, it returns always "no-param", which means, the actionRequest.getParameter()
return null.
So, it seems my processAction
methods gets properly called, but it does not receive the form data. Where is the error, what did I wrong?
Update:
I downloaded the portlet to my local machine, deployed to a local demo Liferay installation, and it worked! So the code should be ok, it must be some server setting/problem. One difference I realized that in the network tab of the Chrome developer tools, the local server has only one POST call with status 200 while on the remote server there is a POST with 302 Moved Temporarily and a GET 200 with the same URL! Could it cause the problem?
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
on your jsp as well? Check if the HTML contains fragments of the<portlet:*>
tags. The namespacing should be resolved automatically... – Olaf Kockaui:form
andaui:input
andParamUtil
as suggested below, but without success.actionRequest.getParameterNames()
return an empty set, is this which should store the form values? – ttamas