Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Natalie D
Global Ajax servlet/portlet, how to achieve that?
April 24, 2012 12:26 AM
Answer

Natalie D

Rank: Junior Member

Posts: 55

Join Date: February 6, 2012

Recent Posts

Hi again

Is there possibility to make an ajax calls to one concrete servlet/ portlet from any other portlet?

I'm asking because code below
1<portlet:actionURL name="getUserData" var="getUserData"
2    windowState="<%=LiferayWindowState.EXCLUSIVE.toString()%>">
3    <portlet:param name="ajaxAction" value="getData"></portlet:param>
4</portlet:actionURL>

creates actionURL only for portlet inside which this code has been executed - so my ajax -handling code has to belong to this porlet.
But in my case: four portlets needs the same ajax functionaity - so should the same ajax-handling code be placed in every portlet? It would be ridiculous.

Regards
Natalie
constantin köck
RE: Global Ajax servlet/portlet, how to achieve that?
April 24, 2012 1:13 AM
Answer

constantin köck

Rank: New Member

Posts: 16

Join Date: June 20, 2010

Recent Posts

You could create a fith portlet and put all business logic inside or cross reference the portlets...

The Action URL could be generated with JS from one portlet to the other like in this example:
http://www.liferay.com/de/web/eduardo.lundgren/blog/-/blogs/liferay-portleturl-in-javascript
Or with java:
http://www.liferay.com/de/community/forums/-/message_boards/message/1557513

regards
c
Ravi Kumar Gupta
RE: Global Ajax servlet/portlet, how to achieve that?
April 24, 2012 2:21 AM
Answer

Ravi Kumar Gupta

Rank: Liferay Legend

Posts: 1303

Join Date: June 23, 2009

Recent Posts

See the message thread link shared above.. but few things.
- You could also use DWR for ajax.. >> the servlet you are talking about(global).. I guess DWR serves that purpose. With this you just need to call all dwr util to call the method defined to perform actions. Not for one portlet but should work all the portlets in one war.
- You could use serveResource in place of actionURL which removes need of windowstate Exclusive (generally this depends on requirements)

Experts: correct me if I'm wrong, please. emoticon