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.
我试图从我的RichFaces项目中删除jquery和prototype和Scriptaculous。我不想在那里使用这些库,因为我想在这个项目中使用最新版本的jQuery,并且拥有这些库的3个旧版本会让它变得困难。
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.
我无法在网上找到任何说明RichFaces的哪些部分需要这些库的文档。事实上,我觉得他们决定在那里包括原型和jquery似乎有点疯狂。
3 个解决方案
#1
6
If you are using RichFaces 3.1.x you can add this in your web.xml file
如果您使用的是RichFaces 3.1.x,则可以在web.xml文件中添加它
<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.
如果你想在你自己的代码中使用最新的jQuery,请看看我写的这篇博客文章,解释如何使用你自己的jQuery版本而不会发生冲突。
The basic idea is that you have to use jQuery.noConflict();
You can assign this to your own selector ie: $j = jQuery.noConflict();
基本思想是你必须使用jQuery.noConflict();您可以将它分配给您自己的选择器,即:$ j = jQuery.noConflict();
Then you are free to use your own jQuery version without affecting the version shipped with Richfaces.
然后您可以*使用自己的jQuery版本,而不会影响Richfaces附带的版本。
function showMessages() {
$j("div#messagetextPanel").fadeIn("fast");
}
Richfaces 4.x is bundled with jQuery 1.4
Richfaces 4.x与jQuery 1.4捆绑在一起
#2
3
It is kind of crazy. I'm not sure if this has changed in Richfaces 4 but the following holds true for 3.x.
这有点疯狂。我不确定Richfaces 4中是否有变化,但以下情况适用于3.x.
- Prototype is used for the core Ajax so you can't get rid of that.
- Prototype用于核心Ajax,因此您无法摆脱它。
- Scripatculous is used for
rich:effect
. - Scripatculous用于丰富:效果。
- jQuery is used for components like the date picker.
- jQuery用于日期选择器之类的组件。
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.
但是,您可以升级这些版本并使用您自己的版本,前提是您在web.xml中使用NONE的LoadScriptStrategy并手动将脚本加载到您的页面中。
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>NONE</param-value>
</context-param>
#3
2
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.
Richfaces 3.x为richfaces-ui.jar / META-INF / rich.component-dependencies中的每个组件定义脚本依赖项。不幸的是,大多数Richfaces UI组件都依赖于jQuery和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:
基本的ajax功能(来自ajax4jsf)非常干净,不依赖于jQuery或Prototype。因此,要获得ajax支持,您只需要以下内容:
- /a4j/g/3_3_1.GAorg.ajax4jsf.javascript.AjaxScript
- /a4j/g/3_3_1.GAorg.ajax4jsf.javascript.AjaxScript
- /a4j/g/3_3_1.GAorg/ajax4jsf/javascript/scripts/form.js
- /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.
您可以将它们放在一个自定义文件中,以避免Richfaces单独加载它们。如果要使用自定义脚本,则需要将web.xml中的context-param org.richfaces.LoadScriptStrategy设置为NONE。
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.
如果您想使用UI控件,那么您可能最终必须同时拥有jQuery和原型。但是,您可以将基础jQuery升级到1.4.3。为此,您需要查看Richfaces对jQuery.js进行的调整,并重新应用于更高版本的jQuery。
Richfaces 4 is supposed to be a much cleaner implementation. I hope so!
Richfaces 4应该是一个更清洁的实现。但愿如此!
#1
6
If you are using RichFaces 3.1.x you can add this in your web.xml file
如果您使用的是RichFaces 3.1.x,则可以在web.xml文件中添加它
<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.
如果你想在你自己的代码中使用最新的jQuery,请看看我写的这篇博客文章,解释如何使用你自己的jQuery版本而不会发生冲突。
The basic idea is that you have to use jQuery.noConflict();
You can assign this to your own selector ie: $j = jQuery.noConflict();
基本思想是你必须使用jQuery.noConflict();您可以将它分配给您自己的选择器,即:$ j = jQuery.noConflict();
Then you are free to use your own jQuery version without affecting the version shipped with Richfaces.
然后您可以*使用自己的jQuery版本,而不会影响Richfaces附带的版本。
function showMessages() {
$j("div#messagetextPanel").fadeIn("fast");
}
Richfaces 4.x is bundled with jQuery 1.4
Richfaces 4.x与jQuery 1.4捆绑在一起
#2
3
It is kind of crazy. I'm not sure if this has changed in Richfaces 4 but the following holds true for 3.x.
这有点疯狂。我不确定Richfaces 4中是否有变化,但以下情况适用于3.x.
- Prototype is used for the core Ajax so you can't get rid of that.
- Prototype用于核心Ajax,因此您无法摆脱它。
- Scripatculous is used for
rich:effect
. - Scripatculous用于丰富:效果。
- jQuery is used for components like the date picker.
- jQuery用于日期选择器之类的组件。
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.
但是,您可以升级这些版本并使用您自己的版本,前提是您在web.xml中使用NONE的LoadScriptStrategy并手动将脚本加载到您的页面中。
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>NONE</param-value>
</context-param>
#3
2
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.
Richfaces 3.x为richfaces-ui.jar / META-INF / rich.component-dependencies中的每个组件定义脚本依赖项。不幸的是,大多数Richfaces UI组件都依赖于jQuery和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:
基本的ajax功能(来自ajax4jsf)非常干净,不依赖于jQuery或Prototype。因此,要获得ajax支持,您只需要以下内容:
- /a4j/g/3_3_1.GAorg.ajax4jsf.javascript.AjaxScript
- /a4j/g/3_3_1.GAorg.ajax4jsf.javascript.AjaxScript
- /a4j/g/3_3_1.GAorg/ajax4jsf/javascript/scripts/form.js
- /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.
您可以将它们放在一个自定义文件中,以避免Richfaces单独加载它们。如果要使用自定义脚本,则需要将web.xml中的context-param org.richfaces.LoadScriptStrategy设置为NONE。
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.
如果您想使用UI控件,那么您可能最终必须同时拥有jQuery和原型。但是,您可以将基础jQuery升级到1.4.3。为此,您需要查看Richfaces对jQuery.js进行的调整,并重新应用于更高版本的jQuery。
Richfaces 4 is supposed to be a much cleaner implementation. I hope so!
Richfaces 4应该是一个更清洁的实现。但愿如此!