Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
kishan sahu
Pass data on clicking hyperlink to a specific function in portlet Class
November 16, 2012 5:08 AM
Answer

kishan sahu

Rank: New Member

Posts: 6

Join Date: September 17, 2012

Recent Posts

Hi Friends,

I am having a hyperlink, and on its click i want to send some dynamic data( variables) to a function present in my portlet class,
Can anyone suggest me how I can achieve this.
Vishal Panchal
RE: Pass data on clicking hyperlink to a specific function in portlet Clas
November 17, 2012 5:44 AM
Answer

Vishal Panchal

Rank: Expert

Posts: 280

Join Date: May 20, 2012

Recent Posts

kishan sahu:
Hi Friends,

I am having a hyperlink, and on its click i want to send some dynamic data( variables) to a function present in my portlet class,
Can anyone suggest me how I can achieve this.


First of all you need to learn how to call a specific method from a portlet class.
So , for that you should try as below..

(1) make <liferay-portlet:actionURL>

<liferay-portlet:actionURL name="portletClassMethodName" var="testURL"></liferay-portlet:actionURL>


(2) In your portlet class you should have a method which name is as same as you specified in name attribute of your <liferay-portlet:actionURL>.

public void portletClassMethodName(ActionRequest request, ActionResponse response)
{
// Your code goes here here
}


Now for passing dynamic values within URL all you need to do is to add <portlet:param> dynamically to your URL

So create your action:URL dynamically.
<liferay-portlet:actionURL name="portletClassMethodName" var="testURL">
<portlet:param name="dynamicAttrib" value="dynamicAttribValue" />
</liferay-portlet:actionURL>


(3)
Now your URL is ready just pass it to HREF.

<a href="<%= testURL %>"


(4) in your portlet class method you can get this parameter.

String dynamicAttribValue= ParamUtil.getString(actionRequest, "dynamicAttrib");



Thats it..!!

Thanks&Regards,
Vishal R. Panchal
kishan sahu
RE: Pass data on clicking hyperlink to a specific function in portlet Clas
November 19, 2012 8:50 PM
Answer

kishan sahu

Rank: New Member

Posts: 6

Join Date: September 17, 2012

Recent Posts

Thank you, this was really helpful. thanks