Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
donino pienni
How to include javascript files in a WSRP portlet
October 9, 2012 2:31 PM

donino pienni

Rank: Junior Member

Posts: 82

Join Date: July 2, 2011

Recent Posts

Hi everybody,

In a very simple helloworld portlet i use this liferay-portlet.xml in Liferay 6.1. CE GA2 Tomcat 7 :

 1<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.1.0//EN" "">
 3    <portlet>
 4        <portlet-name>myHelloWorld</portlet-name>
 5                <instanceable>true</instanceable>
 6                <remoteable>true</remoteable>
 7                <header-portlet-javascript>/js/myscript.js</header-portlet-javascript>
 8    </portlet>

This portlet displays HelloWorld, and a button wich invokes a javascript function from /js/myscript.js. The javascript function only displays an alert. It works when it is used as a standard portlet, but i have an issue with the javascript code if i use it as a remote portlet:

As described in the WSRP wiki, i created a WSRP producer and a consumer based on this portlet. My remote portlet is correctly displayed by the consumer but the javascript is not included. It seems a <header-portlet-javascript> file is not correctly processed in a WSRP context.

I join the .war file, please could anyone tell me if i missed someting?
Is there a working example of a WSRP portlet using the "<header-portlet-javascript> " tag?

Any help will be much appreciated.
Attachments: myHelloWorld.war (6.0k)
Kenneth Chang
RE: How to include javascript files in a WSRP portlet
December 11, 2012 1:06 PM

Kenneth Chang

Rank: Junior Member

Posts: 25

Join Date: May 9, 2011

Recent Posts

Are you trying this on localhost? I got it to work by changing 'localhost' to ''.

Bug fix for footers:

Participate in the State of Liferay Community 2017. Help the community and even win some prizes!