Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Nisarg Parikh
Passing textarea value into actionRequest
May 10, 2012 9:06 AM
Answer

Nisarg Parikh

Rank: Expert

Posts: 252

Join Date: December 30, 2009

Recent Posts

Hi All,

I have created on hook for calendar. Created one new tab and page for that tab.
In new jsp I have put below code.



<portlet:actionURL var="editEventURL" windowState="<%= WindowState.MAXIMIZED.toString() %>">
<liferay-portlet:param name="struts_action" value="/calendar/export_events" />
<liferay-portlet:param name="redirect" value="<%= currentURL %>" />
<liferay-portlet:param name="suggestTopic" value="true" />
</portlet:actionURL>


<DIV style="padding-right:10px;">

<br/>Enter your message below:<br/>
<br/>
<textarea style="width: 100%;" name="body" rows="7" wrap="virtual"></textarea>

<br/><br/>

</DIV>

<DIV align="center">
<aui:button onClick="<%= editEventURL %>" value="Send" />
<aui:button onClick="location.href='./ltf'" value="Cancel" />
</DIV>

When it goes to ExportEventsAction.java class, it does not get textarea value. I use below code:

String msgBody = ParamUtil.getString(actionRequest, "body");

I get null only.. Do I need to put <form> tag in jsp?

Please help me with this issue.

Thanks in advance.

-Nisarg
Krzysztof Gołębiowski
RE: Passing textarea value into actionRequest
May 10, 2012 11:29 AM
Answer

Krzysztof Gołębiowski

Rank: Expert

Posts: 334

Join Date: June 25, 2011

Recent Posts

I think you definety need to enclose that texatarea and button within a form tag:

<portlet:actionURL var="editEventURL" windowState="<%= WindowState.MAXIMIZED.toString() %>">
<liferay-portlet:param name="struts_action" value="/calendar/export_events" />
<liferay-portlet:param name="redirect" value="<%= currentURL %>" />
<liferay-portlet:param name="suggestTopic" value="true" />
</portlet:actionURL>

<aui:form action="<%= editEventURL %>" method="post" name="fm">
<aui:input name="body" type="textarea" />
<aui:button type="submit" value='send' />
<aui:form>


Regards,
KG
Subhash Shah
RE: Passing textarea value into actionRequest
May 10, 2012 10:53 PM
Answer

Subhash Shah

Rank: Junior Member

Posts: 77

Join Date: November 29, 2011

Recent Posts

values of input components within <form>......</form> will be available as request parameters in controller method.
Nisarg Parikh
RE: Passing textarea value into actionRequest
May 11, 2012 1:13 AM
Answer

Nisarg Parikh

Rank: Expert

Posts: 252

Join Date: December 30, 2009

Recent Posts

Thanks for your responses.

If I put it in form then there is no action method called. I am not sure why.

If I inspect form element, I can not see the action url. If I put that in button then I see the action url.

I see only this "<form action="" class="aui-form " id="_8_fm" name="_8_fm" method="post">"

Do not know what is happening.

Please help me.

Thank you once again.

-Nisarg
Nisarg Parikh
RE: Passing textarea value into actionRequest
May 11, 2012 1:34 AM
Answer

Nisarg Parikh

Rank: Expert

Posts: 252

Join Date: December 30, 2009

Recent Posts

I have finally done that by liferay way only.


<aui:form method="post" name="fm">

<portlet:actionURL var="editEventURL" windowState="<%= WindowState.MAXIMIZED.toString() %>">
<liferay-portlet:param name="struts_action" value="/calendar/export_events" />
<liferay-portlet:param name="redirect" value="<%= currentURL %>" />
<liferay-portlet:param name="suggestTopic" value="true" />
</portlet:actionURL>

<%
String taglibOnClick = "document." + renderResponse.getNamespace() + "fm.action = '" + editEventURL + "'; document." + renderResponse.getNamespace() + "fm.submit();";
%>


<DIV style="padding-right:10px;">

<br/>Enter your message below:<br/>
<br/>
<aui:input type="textarea" style="width: 100%;" name="body" rows="7" />

<br/><br/>

</DIV>

<DIV align="center">
<aui:button onClick="<%= taglibOnClick %>" value="Send" style="width:90px;" />
<aui:button onClick="location.href='./ltf'" value="Cancel" style="width:90px;" />
</DIV>

</aui:form>


Thanks for the help.

Thank you.

-Nisarg