Fórum

Duplication of resource includes with multiple portlets

J S, modificado 11 Anos atrás.

Duplication of resource includes with multiple portlets

Junior Member Postagens: 31 Data de Entrada: 11/04/12 Postagens Recentes
Hi,

We've suffered from the problem whereby if 2 portlets include the same resource (javascript etc.) then it gets included twice. I saw this issue reported on the Primefaces forum, and described in their bug database, along with a possible solution:

http://code.google.com/p/primefaces/issues/detail?id=2436#c6 I've not found a comparable issue in the faces jira database.

I've implemented the solution proposed and it seems to work well for us.

Would the liferay-faces project be interested in receiving the patch?

Thanks,

John
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
The issue in the Liferay Issue Tracker is FACES-1216 which has a corresponding issue 4093 in the PrimeFaces issue tracker that Çağatay and I have discussed verbally.

Is the problem you're having strictly a JavaScript conflict, or are you referring to a slowdown of page load times due to redundant copies of resources being downloaded?
J S, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Junior Member Postagens: 31 Data de Entrada: 11/04/12 Postagens Recentes
Yes, it was a while ago that I did this but I think I had issues because things like jQuery were being loaded twice. I couldn't just place the jquery.js in the standard header because it was being referred to by JSF component annotations.

Was this going to be on the roadmap for the 3.1 release?

John
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
PrimeFaces 3.1 was released last week, but the release announcement indicates that PrimeFaces 3.3.1 is coming next with some patches that I have provided. The duplicate prime.js issue is on Çağatay's radar screen for 3.3.1, but we will have to wait and see if the fix makes it in 3.3.1.

Note that Çağatay is only focussed on the problem with duplicate prime.js resources -- not duplicate jquery.js resources. At one time I thought that JQuery was able to handle multiple copies/versions of itself on the same page. But I don't know if that's still the case.
J S, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Junior Member Postagens: 31 Data de Entrada: 11/04/12 Postagens Recentes
I've just looked at this again and my problem is caused by the duplicate javascript includes.

I have 2 portlets, they both include jQuery.js .

One portlet also includes a jquery plugin called jQuery.js

I then get this error:

TypeError: jQuery("#mcarousel").jcarousel is not a function


I think what is happening is that the plugin is being applied to one jQuery object, but not the other. If I remove the portlet that doesn't use the carousel plugin then the carousel starts working.

I am using an older version of Primefaces, but I don't think that is really the issue. The carousel javascript is included via a ResourceDependency in a Component I've written, it just so happens that jquery is being included by Primefaces,. If I wasn't using primefaces and including jQuery via a ResourceDependency then this same error would occur if I used my component in 2 different portlets.

So going forward should this be handled by the bridge? My patch seems to work but I need to try it again with the latest release.

John
thumbnail
Hitoshi Ozawa, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
Had the same problem. I just moved my jquery to portal_normal.vm
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
@John: Hitoshi's workaround is good, but I'd be happy to review your patch. If you upload it to the forums as an attachment here, please be aware that you will be required to abide by a contributor agreement.
J S, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Junior Member Postagens: 31 Data de Entrada: 11/04/12 Postagens Recentes
Where can I see the contributor agreement? I'm perfectly happy to abide by it but I need to check that my employer is too.

Thanks,

John
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
Hi John,

It would be great if you could attach your patch to FACES-1216. You should see a "Contribute Solution" button that will provide you with an "I Agree" button with a link to the Contributor Agreement.

Thanks again,

Neil
J S, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Junior Member Postagens: 31 Data de Entrada: 11/04/12 Postagens Recentes
I will do, but I wanted to pass the contributor agreement past my employers, and time zone differences mean it probably won't be till after the weekend.

Thanks,

John
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
OK thanks. emoticon
J S, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Junior Member Postagens: 31 Data de Entrada: 11/04/12 Postagens Recentes
It looks like I can't submit my patch.

However all I did was implement what the issue http://code.google.com/p/primefaces/issues/detail?id=2436#c6 said to do, so I don't think my patch actually would offer any great insight.

Since originally coming across this issue I've also found another problem related to it. If you have several JSF Portlets on the page, all using components that use ResourceDependency annotaions to bring in CSS files then the number of CSS resources on the page can quickly mount up. One page I had had > 80.

IE only supports 32 CSS includes, anything above this is ignored. This basically broke the page in all version of IE.

If each CSS was only included once then this would obviously be less likely to occur.

Is it possibly that this could be looked at again for 3.1 final?

John
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
I just committed a Liferay vendor-specific fix for FACES-1216. Please give it a try as soon as you can. You can download 3.1.0-ga1-SNAPSHOT artifacts from the snapshot repository.
J S, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Junior Member Postagens: 31 Data de Entrada: 11/04/12 Postagens Recentes
It looks like this has fixed the problem. Thanks!

John
thumbnail
Neil Griffin, modificado 11 Anos atrás.

RE: Duplication of resource includes with multiple portlets

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
Thanks for kicking the tires John. I'm glad it worked for you. It would be great to hear from others too, in order to make sure that the fix is working for everyone.