Forums

Home » Liferay Portal » English » 3. Development

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

donino pienni

Rank: Junior Member

Posts: 80

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" "http://www.liferay.com/dtd/liferay-portlet-app_6_1_0.dtd">
 2<liferay-portlet-app>
 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>
 9</liferay-portlet-app>


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.
Thanks
Attachments: myHelloWorld.war (6.0k)
Kenneth Chang
RE: How to include javascript files in a WSRP portlet
December 11, 2012 1:06 PM
Answer

Kenneth Chang

LIFERAY STAFF

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 '127.0.0.1'.


Bug fix for footers: http://issues.liferay.com/browse/LPS-31546