Page navigation with JSF

653 views Asked by At

Probably this is a simple question, but i don't know its answer.

I have a project, myProject. In webContent I have the files home.xhtml, leave.html and I have 2 other folders: cats and dogs. In the cats directoy I have a page cat.xhtml, and in the directory dogs I have a page dogs.xhtml.

I want to go from each page (home,cats, dogs) to page leave.html In each file there is a commandLink

<h:form>
    <h:outputLink value="leave.html" action="#{myBean.leave}">
        <f:verbatim>Leave</f:verbatim>
    </h:outputLink>
</h:form>

myBean in method leave returns a string "leave"

<navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
        <from-outcome>leave</from-outcome>
        <to-view-id>/leave.html</to-view-id>
    </navigation-case>
</navigation-rule>

But this doesn't work. I also tried using <to-view-id>../leave.html</to-view-id> or add a new folder leave and put in there the leave.html page. I used <to-view-id>/leave/leave.html</to-view-id> or <to-view-id>/../leave.html</to-view-id>

but all have the same result HTTP Status 404 /myProject/cats/leave.htlm type Status report

message /myProject/cats/leave.htlm

description The requested resource ( /myProject/cats/leave.htlm) is not available.

1

There are 1 answers

0
besc On

Your navigation is not working because page is always going to "leave.html". h:outpuLink uses value property for navigation. I suggest you use h:commandLink and use value property for display link (Leave) and action property for from-outcome string.

<h:commandLink value="Leave" action="#{myBean.leave}">