my dog learned polymorphism*
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
JavaRanch » Java Forums » Java » JSF
Bookmark "navigate from bean" Watch "navigate from bean" New topic
Author

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
author
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
 
Consider Paul's rocket mass heater.
 
subject: navigate from bean
 
Similar Threads
How to use an Admin and User class in a Web Application
Ecommerce using stripes
Struts2 + Roles Interceptor
Dynamic Forms
How to stop and start EJB using admin console?