所有与 JSF 相关的 web.xml 上下文参数名称和值的概述 [英] Overview of all JSF-related web.xml context parameter names and values

查看:16
本文介绍了所有与 JSF 相关的 web.xml 上下文参数名称和值的概述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

web.xml中有几个JavaServer Faces :facelets.REFRESH_PERIODfacelets.DEVELOPMENTfacelets.SKIP_COMMENTS 等.在哪里可以找到所有这些参数的完整列表?

解决方案

首先,那些以 facelets. 开头的不是 JSF 上下文参数,而是 Facelets 1.x 上下文参数.以前,在 JSF 1.x 时代,Facelets 并未集成为 JSF 的一部分.但是,从 JSF 2.0 开始,Facelets 被集成为 JSF 的一部分,取代了传统的 JSP 作为默认视图技术,并且大部分 Facelets 1.x 上下文参数被重新映射到 JSF 2.x 上下文参数.

真正的 JSF 上下文参数名称以 javax.faces. 开头.它们列在 JSF 规范的第 11.1.3 章中.以下是 JSF 2.0 规范的相关摘录:

<块引用>

11.1.3 应用配置参数

Servlet 容器支持可以通过在 Web 应用程序部署描述符中包含 元素来自定义的应用程序配置参数.所有 JSF 实现都需要支持以下应用程序配置参数名称:

  • javax.faces.CONFIG_FILES -- 上下文相关资源路径的逗号分隔列表,JSF 实现将在这些路径下查找应用程序配置资源(请参阅第 11.4.4 节应用程序配置"Resource Format"),然后加载名为/WEB-INF/faces-config.xml"的配置资源(如果存在这样的资源).如果列表中存在/WEB-INF/faces-config.xml",则必须忽略它.

  • javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE -- 如果设置了这个参数,并在其值的 String 表示上调用 toLowerCase().equals("true") 返回 trueApplication.createConverter() 必须保证所有时区的默认值javax.faces.convert.DateTimeConverter 实例必须等于 TimeZone.getDefault()而不是GMT".

  • javax.faces.DEFAULT_SUFFIX -- 允许 Web 应用程序为 JSP 页面定义备用后缀包含 JSF 内容.有关符号常量,请参阅 javadocsViewHandler.DEFAULT_SUFFIX_PARAM_NAME 用于完整规范.

  • javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER -- 如果设置了这个参数,并且调用toLowerCase().equals("true") 对其值的 String 表示返回 true,默认值ViewHandler 必须按照本规范的最新 1.2 版本中的规定运行.中指定的任何行为第 7.5 节ViewHandler"并在与处理请求相关的默认 ViewHandler 中实现使用 JavaServer Faces 视图声明语言编写的页面不得由运行时执行.

  • javax.faces.FACELETS_LIBRARIES -- 如果设置了此参数,则运行时必须将其解释为分号 (;)分隔的路径列表,以/"开头(不带引号).运行时必须将列表中的每个条目解释为相对于 Web 应用程序根的路径,并将在该路径中找到的文件解释为 facelet 标记库,符合在第 1.1 节应用程序配置资源文件的 XML 架构定义"中声明的架构并公开其中的标签根据第 10.3.2 节Facelet 标签库机制".运行时还必须考虑facelets.LIBRARIES 参数名称作为此参数名称的别名,以便向后兼容现有facelets 标签库.

  • javax.faces.FACELETS_BUFFER_SIZE -- 当 ResponseWriter 响应时设置的缓冲区大小生成.默认情况下,该值为 -1,这不会为响应分配缓冲区大小.这个应该增加如果您使用开发模式是为了保证在出现错误时不会部分呈现响应生成.运行时还必须将 facelets.BUFFER_SIZE 参数名称视为此参数的别名与现有 facelets 标记库向后兼容的名称.

  • javax.faces.DECORATORS -- 以分号 (;) 分隔的类名列表javax.faces.view.facelets.TagDecorator,带有无参数构造函数.这些装饰器将是当对 Facelets VDL 视图的第一个请求命中 ViewHandler 以进行页面编译时加载.运行时还必须将 facelets.DECORATORS 参数名称视为此参数名称的别名,以便向后与现有的 facelets 标签库兼容.

  • javax.faces.FACELETS_REFRESH_PERIOD -- 当一个页面被请求时,以秒为单位的间隔应该是多少?编译器检查更改.如果您不希望编译器在编译页面后检查更改,请使用-1 的值.设置低刷新周期有助于在开发期间能够在运行中编辑页面application.The 运行时还必须考虑 facelets.REFRESH_PERIOD 参数名称作为这个的别名与现有 facelets 标记库向后兼容的参数名称.

  • javax.faces.FACELETS_RESOURCE_RESOLVER -- 如果设置了此参数,则运行时必须将其值解释为扩展 javax.faces.view.facelets.ResourceResolver 的 java 类的完全限定类名并且有一个零参数公共构造函数或一个单参数公共构造函数,其中参数的类型是ResourceResolver.如果设置了此参数并且其值不符合这些要求,则运行时必须记录一条消息并继续.如果它确实符合这些要求并且具有单参数构造函数,则默认ResourceResolver 必须传递给构造函数.如果它有一个零参数构造函数,则直接调用它.无论哪种情况,新的 ResourceResolver 都会替换旧的.运行时还必须考虑facelets.RESOURCE_RESOLVER 参数名称作为此参数名称的别名,以便向后兼容现有的 facelets 标签库.

  • javax.faces.FACELETS_SKIP_COMMENTS -- 如果设置了这个参数,并且调用toLowerCase().equals("true") 对其值的 String 表示返回 true,运行时必须确保 Facelets 源页面中的任何 XML 注释都不会传递给客户端.运行时还必须考虑将 facelets.SKIP_COMMENTS 参数名称作为此参数名称的别名以实现向后兼容性使用现有的 facelets 标签库.

  • javax.faces.FACELETS_SUFFIX -- 允许 Web 应用程序为基于 Facelet 定义备用后缀包含 JSF 内容的 XHTML 页面.有关符号常量,请参阅 javadocsViewHandler.FACELETS_SUFFIX_PARAM_NAME 用于完整规范.

  • javax.faces.FACELETS_VIEW_MAPPINGS -- 如果设置了此参数,则运行时必须将其解释为分号(;) 分隔的字符串列表,用于强制声明应用程序中的某些页面必须解释为使用 Facelets,不管它们的扩展名如何.运行时还必须考虑 facelets.VIEW_MAPPINGSparam name 作为此 param name 的别名,以便与现有的 facelets 应用程序向后兼容.见符号常量 ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME 的 javadocs 完整规范.

  • javax.faces.FULL_STATE_SAVING_VIEW_IDS -- 运行时必须将此参数的值解释为逗号分隔的视图 ID 列表,每个视图 ID 都必须使用状态保存机制保存其状态在 JSF 1.2 中指定.

  • javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL -- 如果设置了这个参数,并且对其值的 String 表示调用 toLowerCase().equals("true") 返回 true,任何UIInput.validate() 的实现必须采取以下附加操作.如果 javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL 上下文参数值为true(忽略大小写),并且 UIInput.getSubmittedValue() 返回一个零长度的 String 调用UIInput.setSubmittedValue(null) 并使用null作为当前提交的值继续处理

  • javax.faces.LIFECYCLE_ID -- 处理时要使用的 Lifecycle 实例的生命周期标识符JSF 请求此 Web 应用程序.如果未指定,则为 JSF 默认实例,由LifecycleFactory.DEFAULT_LIFECYCLE,必须使用.

  • javax.faces.PARTIAL_STATE_SAVING -- 运行时查询的 ServletContext init 参数确定是否应该使用部分状态保存机制.如果未定义,运行时必须确定应用程序的版本级别.

    • 对于 1.2 及以下版本的应用程序,运行时不得使用部分状态保存机制.
    • 对于 2.0 及以上版本的应用程序,运行时必须使用部分状态保存机制.

如果定义了此参数,并且应用程序版本为 1.2 及以下,则运行时不得使用部分状态保存机制.否则,如果定义了此参数,并在 String 上调用 toLowerCase().equals("true")其值的表示返回true,运行时必须使用部分状态机制.否则部分状态不得使用保存机制.

  • javax.faces.PROJECT_STAGE -- 一个人类可读的字符串,描述这个特定的 JSF 应用程序所在的位置软件开发生命周期.有效值为Development"、UnitTest"、SystemTest"或Production",对应类的枚举常量javax.faces.application.ProjectStage.也可以通过 JNDI 设置此值.请参阅 javadoc对于 Application.getProjectStage().

  • javax.faces.STATE_SAVING_METHOD -- 保存状态信息的位置.有效值为server"(通常保存在HttpSession中)和client"(通常保存为后续表单中的隐藏字段提交).如果未指定,则必须使用默认值server".

  • javax.faces.VALIDATE_EMPTY_FIELDS -- 如果设置了这个参数,并且调用toLowerCase().equals("true") 对其值的 String 表示返回 true,所有提交的字段将被验证.这是允许模型验证器决定是否为空值或空值所必需的在当前应用中允许.如果值为 false,则不会将 null 或空值传递给验证器.如果该值为字符串auto",则运行时必须检查当前是否存在 JSR-303 Beans Validation环境.如果是这样,运行时必须像已指定值true"一样继续.如果 JSR-303 Beans 验证不存在于当前环境中,运行时最像已指定值false".如果参数未设置,系统必须表现得好像参数设置为auto".

  • javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR -- 如果设置了这个参数,并且调用toLowerCase().equals("true") 对其值的 String 表示返回 true,运行时不得自动添加验证器 ID 等于符号常量值的验证器javax.faces.validator.VALIDATOR_ID 到默认验证器列表.将此参数设置为 true 将具有禁用 Bean Validation 自动安装到每个视图中每个输入组件的效果应用程序,尽管仍然可以手动安装.

JSF 实现可以选择支持额外的配置参数,以及额外的机制自定义 JSF 实现;但是,依赖这些工具的应用程序将无法移植到其他 JSF实现.

正如您在最后一段中所读到的,JSF 实现也可能有自己的一组上下文参数.对于以 com.sun.faces. 开头的 Mojarra,在此博客中列出:有哪些 Mojarra 上下文参数可用? 对于以 org.apache.myfaces. 开头的 MyFaces,它们是也在他们自己的网站上列出:MyFaces 文档 - Web 上下文参数.>

There are several JavaServer Faces <context-param> in web.xml: facelets.REFRESH_PERIOD, facelets.DEVELOPMENT, facelets.SKIP_COMMENTS etc. Where I can find a complete list of all those params?

解决方案

First of all, those starting with facelets. are not JSF context parameters, but Facelets 1.x context parameters. Previously, during JSF 1.x era, Facelets was not integrated as part of JSF. However, since JSF 2.0, Facelets is integrated as part of JSF, replacing legacy JSP as the default view technology, and most of the Facelets 1.x context parameters were remapped to JSF 2.x context parameters.

The real JSF context parameter names start with javax.faces.. They are listed in chapter 11.1.3 of the JSF specification. Here's an extract of relevance from the JSF 2.0 specification:

11.1.3 Application Configuration Parameters

Servlet containers support application configuration parameters that may be customized by including <context-param> elements in the web application deployment descriptor. All JSF implementations are required to support the following application configuration parameter names:

  • javax.faces.CONFIG_FILES -- Comma-delimited list of context-relative resource paths under which the JSF implementation will look for application configuration resources (see Section 11.4.4 "Application Configuration Resource Format"), before loading a configuration resource named "/WEB-INF/faces-config.xml" (if such a resource exists). If "/WEB-INF/faces-config.xml" is present in the list, it must be ignored.

  • javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE -- If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, Application.createConverter() must guarantee that the default for the timezone of all javax.faces.convert.DateTimeConverter instances must be equal to TimeZone.getDefault() instead of "GMT".

  • javax.faces.DEFAULT_SUFFIX -- Allow the web application to define an alternate suffix for JSP pages containing JSF content. See the javadocs for the symbolic constant ViewHandler.DEFAULT_SUFFIX_PARAM_NAME for the complete specification.

  • javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER -- If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, the default ViewHandler must behave as specified in the latest 1.2 version of this specification. Any behavior specified in Section 7.5 "ViewHandler" and implemented in the default ViewHandler that pertains to handling requests for pages authored in the JavaServer Faces View Declaration Language must not be executed by the runtime.

  • javax.faces.FACELETS_LIBRARIES -- If this param is set, the runtime must interpret it as a semicolon (;) separated list of paths, starting with "/" (without the quotes). The runtime must interpret each entry in the list as a path relative to the web application root and interpret the file found at that path as a facelet tag library, conforming to the schema declared in Section 1.1 "XML Schema Definition for Application Configuration Resource file"and expose the tags therein according to Section 10.3.2 "Facelet Tag Library mechanism". The runtime must also consider the facelets.LIBRARIES param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.

  • javax.faces.FACELETS_BUFFER_SIZE -- The buffer size to set on the response when the ResponseWriter is generated. By default the value is -1, which will not assign a buffer size on the response. This should be increased if you are using development mode in order to guarantee that the response isn't partially rendered when an error is generated. The runtime must also consider the facelets.BUFFER_SIZE param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.

  • javax.faces.DECORATORS -- A semicolon (;) delimitted list of class names of type javax.faces.view.facelets.TagDecorator, with a no-argument constructor. These decorators will be loaded when the first request for a Facelets VDL view hits the ViewHandler for page compilation.The runtime must also consider the facelets.DECORATORS param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.

  • javax.faces.FACELETS_REFRESH_PERIOD -- When a page is requested, what interval in seconds should the compiler check for changes. If you don't want the compiler to check for changes once the page is compiled, then use a value of -1. Setting a low refresh period helps during development to be able to edit pages in a running application.The runtime must also consider the facelets.REFRESH_PERIOD param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.

  • javax.faces.FACELETS_RESOURCE_RESOLVER -- If this param is set, the runtime must interpret its value as a fully qualified classname of a java class that extends javax.faces.view.facelets.ResourceResolver and has a zero argument public constructor or a one argument public constructor where the type of the argument is ResourceResolver. If this param is set and its value does not conform to those requirements, the runtime must log a message and continue. If it does conform to these requirements and has a one-argument constructor, the default ResourceResolver must be passed to the constructor. If it has a zero argument constructor it is invoked directly. In either case, the new ResourceResolver replaces the old one. The runtime must also consider the facelets.RESOURCE_RESOLVER param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.

  • javax.faces.FACELETS_SKIP_COMMENTS -- If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, the runtime must ensure that any XML comments in the Facelets source page are not delivered to the client. The runtime must also consider the facelets.SKIP_COMMENTS param name as an alias to this param name for backwards compatibility with existing facelets tag libraries.

  • javax.faces.FACELETS_SUFFIX -- Allow the web application to define an alternate suffix for Facelet based XHTML pages containing JSF content. See the javadocs for the symbolic constant ViewHandler.FACELETS_SUFFIX_PARAM_NAME for the complete specification.

  • javax.faces.FACELETS_VIEW_MAPPINGS -- If this param is set, the runtime must interpret it as a semicolon (;) separated list of strings that is used to forcibly declare that certain pages in the application must be interpreted as using Facelets, regardless of their extension. The runtime must also consider the facelets.VIEW_MAPPINGS param name as an alias to this param name for backwards compatibility with existing facelets applications. See the javadocs for the symbolic constant ViewHandler.FACELETS_VIEW_MAPPINGS_PARAM_NAME for the complete specification.

  • javax.faces.FULL_STATE_SAVING_VIEW_IDS -- The runtime must interpret the value of this parameter as a comma separated list of view IDs, each of which must have their state saved using the state saving mechanism specified in JSF 1.2.

  • javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL -- If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, any implementation of UIInput.validate() must take the following additional action. If the javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL context parameter value is true (ignoring case), and UIInput.getSubmittedValue() returns a zero-length String call UIInput.setSubmittedValue(null) and continue processing using null as the current submitted value

  • javax.faces.LIFECYCLE_ID -- Lifecycle identifier of the Lifecycle instance to be used when processing JSF requests for this web application. If not specified, the JSF default instance, identified by LifecycleFactory.DEFAULT_LIFECYCLE, must be used.

  • javax.faces.PARTIAL_STATE_SAVING --The ServletContext init parameter consulted by the runtime to determine if the partial state saving mechanism should be used. If undefined, the runtime must determine the version level of the application.

    • For applications versioned at 1.2 and under, the runtime must not use the partial state saving mechanism.
    • For applications versioned at 2.0 and above, the runtime must use the partial state saving mechanism.

If this parameter is defined, and the application is versioned at 1.2 and under, the runtime must not use the partial state saving mechanism. Otherwise, If this param is defined, and calling toLowerCase().equals("true") on a String representation of its value returns true, the runtime must use partial state mechanism. Otherwise the partial state saving mechanism must not be used.

  • javax.faces.PROJECT_STAGE -- A human readable string describing where this particular JSF application is in the software development lifecycle. Valid values are "Development", "UnitTest", "SystemTest", or "Production", corresponding to the enum constants of the class javax.faces.application.ProjectStage. It is also possible to set this value via JNDI. See the javadocs for Application.getProjectStage().

  • javax.faces.STATE_SAVING_METHOD -- The location where state information is saved. Valid values are "server" (typically saved in HttpSession) and "client" (typically saved as a hidden field in the subsequent form submit). If not specified, the default value "server" must be used.

  • javax.faces.VALIDATE_EMPTY_FIELDS -- If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, all submitted fields will be validated. This is necessary to allow the model validator to decide whether null or empty values are allowable in the current application. If the value is false, null or empty values will not be passed to the validators. If the value is the string "auto", the runtime must check if JSR-303 Beans Validation is present in the current environment. If so, the runtime must proceed as if the value "true" had been specified. If JSR-303 Beans Validation is not present in the current environment, the runtime most proceed as if the value "false" had been specified. If the param is not set, the system must behave as if the param was set with the value "auto".

  • javax.faces.validator.DISABLE_DEFAULT_BEAN_VALIDATOR -- If this param is set, and calling toLowerCase().equals("true") on a String representation of its value returns true, the runtime must not automatically add the validator with validator-id equal to the value of the symbolic constant javax.faces.validator.VALIDATOR_ID to the list of default validators. Setting this parameter to true will have the effect of disabling the automatic installation of Bean Validation to every input component in every view in the application, though manual installation is still possible.

JSF implementations may choose to support additional configuration parameters, as well as additional mechanisms to customize the JSF implementation; however, applications that rely on these facilities will not be portable to other JSF implementations.

As you can read in the last paragraph, JSF implementations may also have their own set of context parameters. For Mojarra that are the ones starting with com.sun.faces. which are listed on this blog: What Mojarra context parameters are available? For MyFaces that are the ones starting with org.apache.myfaces. which are also listed on their own site: MyFaces documentation - Web Context Parameters.

这篇关于所有与 JSF 相关的 web.xml 上下文参数名称和值的概述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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