JSF 2.0 and Implicit Navigation

6 views
Skip to first unread message

Justin Harrison

unread,
Nov 1, 2012, 10:14:37 AM11/1/12
to cse-5234---distributed-ente...@googlegroups.com
I was going through my various JSF xhtml files and creating the connections in the faces-config.xml method when I accidentally spelled a method name wrong in faces-config... and the connection still worked!

Turns out there is a feature in JSF 2.0 called "Implicit Navigation" that allows you to connect pages without using faces-config.xml. You just have to put the page name (without the extension) as your outcome string. By way of example: If you have two pages, one called page1.xhtml and another called page2.xhtml, and you want to link them together using a command button on page1 that transitions to page2, you can do the following:

<h:commandButton action="page2" value=Go to page2" />

You can also do the following in your managed bean:

<h:commandButton action="#{SomeBean.goToPage2}" value="Go to page2" />

if you add to SomeBean:

public String goToPage2() {
return "page2"; //Sends you to page2
}

Doing it in your managed bean allows you to conditionally redirect to different pages without touching the faces-config.

This feature will save me a lot of time, so Dr. Ramnath asked me to post it here so that other teams can benefit too if they have not yet discovered this feature.
Reply all
Reply to author
Forward
0 new messages