Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Terry Jeske
header-portal-javascript creates multiple references -bug?
June 24, 2010 5:00 PM
Answer

Terry Jeske

Rank: Junior Member

Posts: 42

Join Date: June 23, 2010

Recent Posts

I added following tag to the liferay-portlet.xml file for two custom portlets:

<header-portal-javascript>/html/js/js-ext/jquery-1.4.2.js</header-portal-javascript>

Loading them both into a portal pages shows the following in the header:

<script type="text/javascript" src="/html/js/js-ext/jquery-1.4.2.js?browserId=firefox&amp;minifierType=js&amp;languageId=en_US&amp;t=1277422536000"></script>

and

<script type="text/javascript" src="/html/js/js-ext/jquery-1.4.2.js?browserId=firefox&amp;minifierType=js&amp;languageId=en_US&amp;t=1277422620000"></script>

Note that when both of these tags are rendered, the jQuery calls fail. If I only add the header-portal-javascript line to one portlet (removing it from the other), and add both portlets to the page, the jQuery calls work.

Is this a bug? The in a different post Ray stated:

Notice it's called header-portal-javascript, implying that it will be loaded into the portal header (but only when it's on the page, and it won't add the same file twice).
Terry Jeske
RE: header-portal-javascript creates multiple references -bug?
June 25, 2010 9:00 AM
Answer

Terry Jeske

Rank: Junior Member

Posts: 42

Join Date: June 23, 2010

Recent Posts

I think I understand why there are multiple references created in the header. They are needed in case the other portlet gets removed from the page.
e.g.
<script type="text/javascript" src="/html/js/js-ext/jquery-1.4.2.js?browserId=firefox&amp;minifierType=js&amp;languageId=en_US&amp;t=1277422536000"></script>

Still, the fact that having the <header-portal-javascript>/html/js/js-ext/jquery-1.4.2.js</header-portal-javascript> in both portlets causes jquery to fail is a problem.

Any suggestions? I am using Liferay 6 btw.