com.sun.faces.config.ConfigureListener的配置 [英] Configuration of com.sun.faces.config.ConfigureListener

查看:197
本文介绍了com.sun.faces.config.ConfigureListener的配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在审查当前的JSF项目,其中web.xml配置包含:

I'm reviewing a current JSF project where the web.xml configuration contains:

  • FacesServlet(在*.xhtml上配置)
  • com.sun.faces.config.ConfigureListener
  • the FacesServlet (configured on *.xhtml)
  • the com.sun.faces.config.ConfigureListener

我正在使用JSF 2.2和Mojarra实现.

I'm using JSF 2.2 and Mojarra implementation.

我对ConfigureListener感到困惑.配置中是否需要此类?本课程的目标是什么?我找不到任何信息,该类几乎没有javadoc.

I'm confused about the ConfigureListener. Is this class needed in the configuration? What is the goal of this class? I couldn't find any information and the class has almost no javadoc.

如果我删除此配置,则一切似乎都以相同的方式工作.因此,我猜想ConfigureListener可以或应该删除,但是我不确定.

If I remove this configuration, everything seem to work the same way. Thus I guess that the ConfigureListener could or should be removed but I am not sure.

推荐答案

ConfigureListener通常是通过Mojarra实现JAR文件的/META-INF/jsf_core.tld文件自动注册的.此外,ConfigureListener是通过Servlet 3.0 ServletContainerInitializer显式注册的,以解决旧的GlassFish v3错误(注意:v3,而不是3.0.x,因此实际上是第一个GF3版本).

The ConfigureListener is normally automatically registered via /META-INF/jsf_core.tld file of Mojarra implementation JAR file. Additionally, the ConfigureListener is explicitly registered via a Servlet 3.0 ServletContainerInitializer in order to workaround an old GlassFish v3 bug (note: v3, not 3.0.x, thus really that one first GF3 version ever).

存在通过.tld文件自动注册不足的情况.众所周知的是,何时将Web应用程序部署到 Jetty .在此问答中对此进行了详细说明:找不到工厂: javax.faces.context.FacesContextFactory .

There exist situations wherein the auto-registration via .tld file is insufficient. The well known one is when the webapp is deployed to Jetty. This is explained in detail in this Q&A: could not find Factory: javax.faces.context.FacesContextFactory.

此外,如之前和该详细答案中所述,GlassFish v3有一个错误,其中TLD文件被扫描得太晚,因此JSF无法在正确的时机执行其必要的初始化操作.然后,您需要在Webapp的web.xml中显式注册ConfigureListener.

Also, as mentioned before and in that detailed answer, GlassFish v3 has a bug wherein the TLD file is scanned too late and thus JSF couldn't do its necessary initialization thing at the right moment. You'd then need to explicitly register the ConfigureListener in webapp's web.xml.

但是如果未在web.xml中显式注册它时对您有用,那么就将其保留. web.xml中的噪声越小越好.但是,如果您可能会部署到对上述问题敏感的容器(因此,当您的Web应用实际上是公开发行的,并且您无法控制目标容器的选择时),则最好将其保留在针对这种情况"那".

But if it works for you when it's not explicitly registered in web.xml, then just keep it out. Less noise in web.xml is better. But if you happen to possibly deploy to a container sensitive to the mentioned problem (so when your webapp is actually a publicly distributed one and you have no control over choice of target container), then you'd better keep it in "for the case that".

更新:当在web.xml中启用该条目时,Tomcat 8.x似乎显示了错误的行为:此侦听器实际上将执行两次,而不是仅执行一次.结果是灾难性的:除其他外,所有JSF事件侦听器将被注册两次,组件库将被加载两次.这只会导致运行时发生冲突.换句话说,在部署到Tomcat时,请确保已从web.xml中删除该条目.

Update: It appears that Tomcat 8.x shows buggy behavior when this entry is enabled in web.xml: this listener will actually be executed twice instead of only once. The consequence is disastrous: among others, all JSF event listeners will be registered twice and component libraries will be loaded twice. This leads only to conflicts during runtime. In other words, when deploying to Tomcat, make sure that this entry is removed from web.xml.

这篇关于com.sun.faces.config.ConfigureListener的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆