Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JSF2中faces-config.xml的用途是什么?_Jsf_Jsf 2_Faces Config - Fatal编程技术网

JSF2中faces-config.xml的用途是什么?

JSF2中faces-config.xml的用途是什么?,jsf,jsf-2,faces-config,Jsf,Jsf 2,Faces Config,在JSF2对注释的巨大支持之后,我想知道我会使用faces config.xml做什么。现在它的重要性是什么 换句话说,哪些配置只能通过faces config.xml完成,而不能通过注释完成 现在我使用它的目的就是声明Spring的EL解析器 <?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http

在JSF2对注释的巨大支持之后,我想知道我会使用
faces config.xml
做什么。现在它的重要性是什么

换句话说,哪些配置只能通过
faces config.xml
完成,而不能通过注释完成

现在我使用它的目的就是声明Spring的EL解析器

<?xml version="1.0" encoding="UTF-8"?>
<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">

    <application>
        <el-resolver>
            org.springframework.web.jsf.el.SpringBeanFacesELResolver
        </el-resolver>
    </application> 
</faces-config>

org.springframework.web.jsf.el.SpringBeanFacesELResolver

它仍然用于许多无法注释的东西。例如,自定义JSF验证消息:

<application>
    <message-bundle>com.example.i18n.messages</message-bundle>
</application>
自定义工厂,例如自定义异常处理程序工厂(它还允许工厂,以及更多工厂,以便您可以提供自定义实现):


com.example.SomeExceptionHandlerFactory

仅列出常用的。如果您的IDE中有
faces config.xml
tag autocompletion,那么您可以找到它们。由于新的注释和隐式导航,不再需要托管bean、验证器、转换器、组件、渲染器和点对点导航案例。

@Matt:我有一个项目,其中a
java.util.HashMap
as
{components}
存储在请求范围中,以便更好地对所有组件绑定进行声明性概述。例如,
binding=“#{components.foo}”
,这样它就可以被引用为
{components.foo}
,与
binding=“#{foo}”
{foo}
相比,它更具自文档性,风险更小(由于潜在的名称冲突)。我还在寻找一些用于指定el解析器的注释。现在我认为没有办法通过注释指定这些应用程序属性..对..???@RupMajumder你想把这样的注释放在哪里,我的意思是放在什么类上?此属性分布在整个application.FWIW上,当使用Apache Deltaspike时,JsfPhaseListener注释可用于使用阶段侦听器,而无需在faces-config.xml中配置它们。为什么我们需要指定内置解析程序?我认为设计理念是约定而不是配置……我的
faces config.xml中也没有
,它工作得非常好。
<application>
    <resource-bundle>
        <base-name>com.example.i18n.Text</base-name>
        <var>text</var>
    </resource-bundle>
</application>
<application>
    <locale-config>
        <default-locale>en</default-locale>
        <supported-locale>nl</supported-locale>
        <supported-locale>es</supported-locale>         
        <supported-locale>de</supported-locale>         
    </locale-config>
</application>
<application>
    <view-handler>com.example.SomeViewHandler</view-handler>
</application>
<lifecycle>
    <phase-listener>com.example.SomePhaseListener</phase-listener>
</lifecycle>
<managed-bean>
    <description>Current date and time</description>
    <managed-bean-name>now</managed-bean-name>
    <managed-bean-class>java.util.Date</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<factory>
    <exception-handler-factory>com.example.SomeExceptionHandlerFactory</exception-handler-factory>
</factory>