0
votes

I am lerning JSF from some Udemy tutorial and the guy there has the following code underneath in the faces-config.xml. With this code I am getting the following error:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'from-outcome'. One of '{"http:// xmlns.jcp.org/xml/ns/javaee":to-view-id}' is expected.

The guy has the <if> tag in the Navigation-case before the <from-outcome> as in the code. How can I get ride of this error?

faces-config.xhtml

<?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>
        <from-view-id>/pages/welcome.xhtml</from-view-id>

        <navigation-case>
            <if>#{clasifBean.age le 11}</if>
            <from-outcome>go</from-outcome>
            <to-view-id>/pages/age/kid</to-view-id>
            <redirect />
        </navigation-case>

        <navigation-case>
            <if>#{clasifBean.age gt 11 and clasifBean.age lt 40}</if>
            <from-outcome>go</from-outcome>
            <to-view-id>/pages/age/teen</to-view-id>
            <redirect />
        </navigation-case>

        <navigation-case>
            <if>#{clasifBean.age ge 40}</if>
            <from-outcome>go</from-outcome>
            <to-view-id>/pages/age/old</to-view-id>
            <redirect />
        </navigation-case>

    </navigation-rule>



</faces-config>
1

1 Answers

0
votes

I solved the Problem after putting the if condition after from-outcome like this:

   <navigation-case>
        <from-outcome>go</from-outcome>
         <if>#{clasifBean.age le 11}</if>
        <to-view-id>/pages/age/kid</to-view-id>
        <redirect />
    </navigation-case>