开发者

Which RichFaces components use prototype, which use jquery?

I am trying to remove jquery and prototype and Scriptaculous from my RichFa开发者_运维百科ces 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.


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


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>


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜