This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSF and the fly likes JSF with Facelets - Using Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF with Facelets - Using "h:commandLink" inside header of the layout" Watch "JSF with Facelets - Using "h:commandLink" inside header of the layout" New topic
Author

JSF with Facelets - Using "h:commandLink" inside header of the layout

Daniel Reznick
Ranch Hand

Joined: Oct 23, 2008
Posts: 50

Hi!

I recently added facelets ability to my web app based on JSF

I have added a header.xhtml so it will be displayed on top of each page...

now i want to add a link inside the header, link which will take the user to the "Home" of the webapp, something like this:


and i added to faces-config.xml the following mapping :


but it does not work... the only way i managed to make it work is to add a mapping into faces-config.xml which will point from each page for example TestMenu.xhtml in my web app to the /MainMenu.xhtml using this <from-outcome>Home</from-outcome>
like this:


But... I don't want to use this solution cause it'll force me to add allot of mapping into the faces-config.xml file...

How can i solve this problem with minimum edit inside the faces-config.xml file?

Thanks ahead...

Daniel.

[ October 23, 2008: Message edited by: Daniel Reznick ]
[ October 23, 2008: Message edited by: Daniel Reznick ]
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Just remove the value from the from-view-id element. The from-view-id qualifies what view the mapping applies to. If you omit it, the default is that it applies to all views.

The name of the view is based on the entire page, not specific sections within it, which is where your original problem came from.


Customer surveys are for companies who didn't pay proper attention to begin with.
Daniel Reznick
Ranch Hand

Joined: Oct 23, 2008
Posts: 50

Thanks!

worked like charm
[ October 26, 2008: Message edited by: Daniel Reznick ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSF with Facelets - Using "h:commandLink" inside header of the layout