升级到JSF 2.2后faces-config中的错误

时间:2017-04-24 14:28:27

标签: jsf-2.2 myfaces faces-config

将项目中的JSF实现从Myfaces 1.1升级到MyFaces 2.2.12之后,我的IDE(IntelliJ)显示了我navigation-rule中所有managed-beanfaces-config.xml条目的错误。我已经从

更改了该文件中的根元素
<!DOCTYPE faces-config PUBLIC
        "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
        "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

<faces-config>

<faces-config
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">

navigation-rule以下条目曾经起作用,并且在升级之前没有显示任何错误:

<navigation-rule>
    <navigation-case>
        <from-outcome>exampleOutcome</from-outcome>
        <to-view-id>/newpages/view1.jsp</to-view-id>
    </navigation-case>
</navigation-rule>

升级到JSF 2.2后,navigation-case元素带有红色下划线错误标记。当用鼠标悬停文本时,我收到错误消息:

Invalid content was found starting with element 'navigation-case'. One of '{"http://xmlns.jcp.org/xml/ns/javaee":from-view-id}' is expected.

这是否意味着from-view-id已成为JSF 2.2的强制性要求?

managed-bean条目,如

<managed-bean>
    <managed-bean-name>ExampleBean</managed-bean-name>
    <managed-bean-class>my.example.package.ExampleBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

产生类似的错误消息:

A field of identity constraint 'faces-config-managed-bean-name-uniqueness' matched element 'faces-config', but this element does not have a simple type.

我还没有发现任何关于结构变化的事情,因为升级到JSF 2.2后这一点变得必不可少。 有趣的是,我没有通过对JSF 2.1的中间更改来获得此错误!

有人能指出我可能有助于解决这个问题的方向吗?

1 个答案:

答案 0 :(得分:0)

试试这个:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config


xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">
<navigation-rule>
    <display-name>first_page.xhtml</display-name>
    <from-view-id>/first_page.xhtml</from-view-id>
    <navigation-case>
        <to-view-id>/second_page.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>