This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JSF and the fly likes navigate from bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "navigate from bean" Watch "navigate from bean" New topic

navigate from bean

bostian tov
Ranch Hand

Joined: Mar 11, 2010
Posts: 32
I have method that checks if logged on user is admin or not. How can i make redirect in bean, when i know if user is not admin. I have made navigation rule, but dont know how to go further. Thanks
Bart Kummel
Ranch Hand

Joined: Nov 30, 2007
Posts: 81
Hi Bostian,

One of the most simple solutions is to have your action method return a String for the desired navigation case. For example, suppose you have the following button:

Then your managedBean should have a method like this:

You should have two navigation cases in your faces-config.xml: adminAction and normalUserAction. Each navigation case should lead to the desired page.

Good luck!

Best regards,
Bart Kummel

SCJP 1.4 | SCJD 1.6 | Visit my website | Author of the book Apache MyFaces 1.2 Web Application Development
subject: navigate from bean