Reputation: 190
After upgrading the JSF implementation in our project from Myfaces 1.1 to MyFaces 2.2.12, my IDE (IntelliJ) shows me errors for all navigation-rule
and managed-bean
entries in my faces-config.xml
. I have changed the root element in that file from
<!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>
to
<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
entries like the following used to work and didn't show any errors before the upgrade:
<navigation-rule>
<navigation-case>
<from-outcome>exampleOutcome</from-outcome>
<to-view-id>/newpages/view1.jsp</to-view-id>
</navigation-case>
</navigation-rule>
After the upgrade to JSF 2.2, the navigation-case
element is error-marked with a red underline. When hovering the text with the mouse, I get the error message:
Invalid content was found starting with element 'navigation-case'. One of '{"http://xmlns.jcp.org/xml/ns/javaee":from-view-id}' is expected.
Does this mean the from-view-id
has become obligatory with JSF 2.2?
managed-bean
entries like
<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>
produce the similar error message:
A field of identity constraint 'faces-config-managed-bean-name-uniqueness' matched element 'faces-config', but this element does not have a simple type.
I haven't found anything about structural changes like this becoming necessary with the upgrade to JSF 2.2. Interestingly, I didn't get this error with an intermediate change to JSF 2.1!
Could anyone point me in a direction that might help this problem?
Upvotes: 0
Views: 3201
Reputation: 1
You have to insert an empty tag <from-view-id></from-view-id>
before <navigation-case>
.
Example:
<navigation-rule>
<from-view-id></from-view-id>
<navigation-case>
<from-outcome>go_start</from-outcome>
<to-view-id>/pages/start.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
Upvotes: 0
Reputation: 25
Try this :
<?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>
Upvotes: -1