-
1. Re: JQuery loading twice and overwriting my plugins
yyq2009 Jun 8, 2012 11:34 PM (in response to devinderpal)Hi, hope these links could help you.
Re-routing JSF resource requests with RichFaces Resource Mapping
http://yyq2007aa.blog.163.com/blog/static/44181609201242794212780/
-
2. Re: JQuery loading twice and overwriting my plugins
devinderpal Jun 9, 2012 6:47 PM (in response to yyq2009)I have already tried resource mapping. After resource mapping, it's using same version of JQuery with same URL. But still overwriting my JQuery plugins.
Any help will be appreciated
-
3. Re: JQuery loading twice and overwriting my plugins
yyq2009 Jun 10, 2012 12:51 AM (in response to devinderpal)Hi, do it step by step following the article
http://yyq2007aa.blog.163.com/blog/static/44181609201242794212780/
and your resource mapping file should be:
jquery.js=org.richfaces.staticResource/jquery.js
and finally you should load jquery firstly yourself before your own javascript as the following line:
<h:outputScript name="jquery.js" library="org.richfaces.staticResource"/>
Path of jquery.js:
YourWebApp/resources/org.richfaces.staticResource/jquery.js
If you had read the article Re-routing JSF resource requests with RichFaces Resource Mapping, you would pay attention to one of the replies:
Hey guys,
this is really the issue I have introduced with limiting resources to specific libraries, thanks for pointing to that!
I have reported it here: https://issues.jboss.org/browse/RF-11888
Currently, as Grzegorz said, you need to move all the resources to some of those libraries, it means e.g.:
# the configuration for mapping:
jquery.js=org.richfaces.staticResource/jquery-alternative-version.js
# where should the resource be located:
{MAVEN_WAR_PROJECT}/src/main/webapp/resources/org.richfaces.staticResource
{MAVEN_JAR_PROJECT}/src/main/resources/org.richfaces.staticResource/
{JAR}/META-INF/resources/org.richfaces.staticResource/
{WAR}/resources/org.richfaces.staticResource/Good luck.
-
4. Re: JQuery loading twice and overwriting my plugins
devinderpal Jun 12, 2012 9:35 AM (in response to yyq2009)This doesn't help. As I mentioned before, resource mapping can help in using same version of JQuery from the same URL. But still it will override JQuery plugins linked to first mention of jquery library.
I think I have to raise a jira for this issue. I think richfaces should provide a configuration that can be used to restrict any reload of static resources.
-
5. Re: JQuery loading twice and overwriting my plugins
feder Nov 3, 2012 12:58 PM (in response to devinderpal)I agree with jboss fan99. We need to find a way to determine the sequence of the JS libraries in Richfaces 4.2.3+. The JIRA issue is recorded: https://issues.jboss.org/browse/RF-12537
Use Case: Implementing a JavaScript functionality, which is employing jquery.js library, is loaded before the RF-jQuery libraries. Subsequently the JavaScript DOM might be refreshed with objects by the 2nd initialisation of the jQuery library. The rebuild of these objects in jQuery (e.g. global variables/functions), remove the established objects of the primary loaded jQuery library.
Workaround: Place the script(s) of your custom functionality (which depends on the jQuery library, too), right below your html body tag. Remove the initialisation of <h:outputScript name="js/jquery-1.7.1.min.js"> from your html header area. Ensure you are using at least one RF tag (e.g. <rich:inplaceInput .../>) in your xhtml file in order to trigger the RF javascript injection, which loads the jquery library once - and thus only once. Omiting a richface tag, makes your snippet throw an error.
Workaround Limitation: Note, if your snippet of JavaScript functionality demands jQuery functionality before the body html, of course, this workaround does little to support you.
(Awkward, I know. i.e. "workaround")
Solutions: If any solutions occur, please post to this thread.