4

I am having trouble navigating between my JSF pages. Most of my navigation happens when you click a command button. The action of the command button returns a string.

My log in page is my welcome page. Here it is in my web.xml:

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>faces/pages/index.xhtml</welcome-file>
</welcome-file-list>

In my browser's address bar, the page appears as:

http://localhost:8080/ui/faces/pages/index.xhtml

Once authentication happens, the function returns this String:

"/ui/faces/pages/home.xhtml"

The file I want to navigate to is located at:

pages/home.xhtml

However when navigation is supposed to happen, I get this error:

Unable to find matching navigation case with from-view-id '/pages/index.xhtml' for action '#{indexPageController.login()}' with outcome '/ui/faces/pages/home.xhtml'

Can anyone help me understand the relative path I need to correctly navigate to the page?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user489041
  • 27,916
  • 55
  • 135
  • 204
  • While correcting a few typos in your post, I noticed the return string file extension (xhtm) did not match the one in the error message (xhtml). May be you should make sure you don't have a simple typo problem. Otherwise, no idea. I guess you deployed a webapp called "ui". – Alain Pannetier Dec 20 '12 at 00:03
  • @AlainPannetier Thanks, that was just a type, when I wrote up the question. The real String is xhtml. Thanks again – user489041 Dec 20 '12 at 00:05

1 Answers1

5

You should not include the context path /ui nor the FacesServlet mapping /faces in the navigation case outcome. It should just represent the sole view ID, which is basically just the path to the physical view file absolute to the webcontent root or relative to the current view ID.

So, absolute (starting with /) to the webcontent root:

/pages/home.xhtml

Or relative (not starting with /) to the current view ID (assuming that you're in /pages/index.xhtml):

home.xhtml

Do note that dot-slash ./ and double-dot-slash ../ notations are not supported.

Or even without file extension; JSF will imply the Facelets default suffix which defaults to .xhtml and is configureable by javax.faces.DEFAULT_SUFFIX context parameter:

/pages/home
home

It makes after all also sense if you realize that the context path /ui and the FacesServlet mapping /faces/* are not controllable from inside the webapp on! If they ever change externally, then you'd theoretically need to change all navigation case outcomes in the entire codebase and rebuild the webapp. This would not make any sense. JSF takes thus already care of them for you.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555