I have a problem, how can I send my data from html form in jsp (portlet) to controller? Here some code
Portlet JSP
<form id="smsSender" method="post" action="${sendSmsUrl}">
<input type="text" name="phoneSuffix" maxlength="7"/>
<textarea id="message" maxlength="70" name="message"></textarea>
<br>
<input type="submit" value="Send">
</form>
<portlet:actionURL name="sendSms" var="sendSmsUrl">
</portlet:actionURL>
Controller
@Controller
@RequestMapping("VIEW")
public class SmsController extends MVCPortlet {
@ActionMapping
public void sendSms(ActionRequest request, ActionResponse response) {
String message = ParamUtil.get(request, "message", "");
}
}
Please, help me understand how to do it correctly? Thanks!
The problem seems to be because of qualified parameters for portlet:
Possible solution are:
i. Use aui html tags.
<aui:form id="smsSender" method="post" action="${sendSmsUrl}">
<aui:input type="text" name="phoneSuffix" maxlength="7" />
<aui:input type="textarea" id="message" maxlength="70" name="message" />
<br />
<aui:button type="submit" value="Send" />
</form>
OR
ii. Add <portlet:namespace />
to the field(s) name attribute:
<textarea id="<portlet:namespace />message"
maxlength="70" name="<portlet:namespace />message"></textarea>
OR
iii. Add <requires-namespaced-parameters>false</requires-namespaced-parameters>
in
liferay-portlet.xml