Read Data From Action URL

Arun Pandian, modified 5 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
Hi, i have an action url say ,


<liferay-portlet:actionURL name="delete" var="delete">
      <param name="entryId" value="<%= entry.getPostId() %>"/>
</liferay-portlet:actionURL>

How do i read these entryId parameter in my controller method

i have tried

   
ParamUtil.getLong(actionRequest, "entryId");
and
actionRequest.getParameter("entryId")


I am using liferay  7.2 GA1
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Based on the snippet you provided, it should be in there and accessible using either method you've tried.

I would recommend stepping back and ensuring that the action is actually invoking the right method, the action url is bound to a form or a button or something so you know this action is the one being invoked and not some other, the value used for entryId in the JSP actually has a value (could it be null, for example?), etc. You're kind of assuming that just because the JSP snippet is right the whole thing is right, but clearly that doesn't seem to be the case.
Arun Pandian, modified 5 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
David H Nebinger:

Based on the snippet you provided, it should be in there and accessible using either method you've tried.

I would recommend stepping back and ensuring that the action is actually invoking the right method, the action url is bound to a form or a button or something so you know this action is the one being invoked and not some other, the value used for entryId in the JSP actually has a value (could it be null, for example?), etc. You're kind of assuming that just because the JSP snippet is right the whole thing is right, but clearly that doesn't seem to be the case.


Hi, It is a action item from dropdown menu
<liferay-ui:icon-menu direction="left-side" icon="<%=StringPool.BLANK%>"
    markupView="lexicon" message="actions" showWhenSingleIcon="<%=true%>"><liferay-portlet:actionURL name="delete" var="delete">
      <param name="entryId" value="<%= entry.getPostId() %>"/>
</liferay-portlet:actionURL>

    <liferay-ui:icon message="delete" url="<%= delete %>" />
</liferay-ui:icon-menu>


And i verified that the data is passing to the entryId by printing the entry.getPostId() in jsp page and the method delete is also calling because i able to see the system.out.println method from there when i have called the method.


will the value pass if i use "${entry.getPostId()}" instead of <%= entry.getPostId() %> ?
thumbnail
Aravinth Kumar, modified 5 Years ago. Regular Member Posts: 152 Join Date: 6/26/13 Recent Posts
Use liferay-portlet:param instead of param and also check in the chrome network if your value is getting passed properly.
Arun Pandian, modified 5 Years ago. Junior Member Posts: 72 Join Date: 9/26/19 Recent Posts
Thanks that worked !!!!
thumbnail
David H Nebinger, modified 5 Years ago. Liferay Legend Posts: 14933 Join Date: 9/2/06 Recent Posts
Aravinth Kumar:

Use liferay-portlet:param instead of param and also check in the chrome network if your value is getting passed properly.


Great catch Aravinth, I totally missed that!