When I try to acquire the data submitted in a form in Liferay 6.2 it returns null values as if the form data was being thrown away.
JSP:
<liferay-portlet:actionURL var="link">
<liferay-portlet:param name="action" value="doSomething"/>
</liferay-portlet:actionURL>
<form:form method="POST" action="${link}">
<label>
<select id="comboSelect" name="comboSelect">Options:
<option value="1">FOO</option>
<option value="2">BAR</option>
</select>
</label>
<input type="submit"/>
</form:form>
Controller:
@ActionMapping(params = { "action=doSomething" }, method = RequestMethod.POST)
public void doSomething(@RequestParam(value = "comboSelect") String selection){
System.out.print(selection);
}
Why is this happening?
You should either put a namespace prefix to your name
value like this:
<input type="text" name="<portlet:namespace />inputTextName" />
or you can set the requires-namespaced-parameters
setting to false in your liferay-portlet.xml
.
This is a change since Liferay 6.2: https://github.com/liferay/liferay-aui-upgrade-tool/issues/30
They decided to make forms a bit more strict from 6.2. Making it false by default is still in debate on the Liferay forums, as far as I know, so it may become automatic, but for now you have to handle namespacing manually.