Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which RichFaces components use prototype, which use jquery?

I am trying to remove jquery and prototype and Scriptaculous from my RichFaces project. I dont want those libs in there because i want to use the latest version of jQuery in this project, and having 3 old versions of these libs makes it difficult.

I cant find any docs online that say which parts of RichFaces require these libs. In fact, it seems kind of crazy to me that they decided to include both prototype and jquery in there.

like image 393
mkoryak Avatar asked Nov 09 '10 18:11

mkoryak


3 Answers

If you are using RichFaces 3.1.x you can add this in your web.xml file

<context-param>
   <param-name>org.richfaces.ExcludeScripts</param-name>
   <param-value>Prototype,Scriptaculous,JQuery</param-value>
</context-param>

However, this will not work in later versions. More information here.

If you want to use the latest jQuery in your own code, have a look at this blog post I wrote explaining how you can use your own jQuery version without conflicts.

The basic idea is that you have to use jQuery.noConflict(); You can assign this to your own selector ie: $j = jQuery.noConflict();

Then you are free to use your own jQuery version without affecting the version shipped with Richfaces.

function showMessages() {
  $j("div#messagetextPanel").fadeIn("fast");
}

Richfaces 4.x is bundled with jQuery 1.4

like image 116
Shervin Asgari Avatar answered Oct 01 '22 09:10

Shervin Asgari


It is kind of crazy. I'm not sure if this has changed in Richfaces 4 but the following holds true for 3.x.

  • Prototype is used for the core Ajax so you can't get rid of that.
  • Scripatculous is used for rich:effect.
  • jQuery is used for components like the date picker.

You will however be able to upgrade versions of these and use your own provided that you use a LoadScriptStrategy of NONE in your web.xml and load your scripts manually into your pages.

<context-param>
    <param-name>org.richfaces.LoadScriptStrategy</param-name>
    <param-value>NONE</param-value>
</context-param>
like image 39
Damo Avatar answered Oct 01 '22 10:10

Damo


Richfaces 3.x defines script dependencies for each component in richfaces-ui.jar/META-INF/rich.component-dependencies. Unfortunately most of the Richfaces UI components have a dependencies on both jQuery and Prototype.

The basic ajax functionality (which came from ajax4jsf) is pretty clean and doesn't rely on either jQuery or Prototype. So to get ajax support working you just need the following:

  • /a4j/g/3_3_1.GAorg.ajax4jsf.javascript.AjaxScript
  • /a4j/g/3_3_1.GAorg/ajax4jsf/javascript/scripts/form.js

You can pull these together in a custom file to avoid having them loaded individually by Richfaces. You'll need to set the context-param org.richfaces.LoadScriptStrategy in web.xml to NONE if you want to use a custom script.

If you are wanting to use the UI controls, then you'll probably end up having to have both jQuery and prototype. However, you can upgrade the underlying jQuery to 1.4.3 for example. To do this you'll need to look at the tweaks that Richfaces makes to jQuery.js and reapply to the later version of jQuery.

Richfaces 4 is supposed to be a much cleaner implementation. I hope so!

like image 28
willy Avatar answered Oct 01 '22 10:10

willy