How to redirect in a jsf?

User clicks on a menu item that takes him to a.jsp. a.jsp should check whether a particular attribute exists in the session or not. If it doesn't it should redirect the user to b.jsp.

I know how to do this with a servlet (using requestdespatcher). But JSF doesn't have a front controller (it has backing beans only). So how do i go about doing this?

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)

Jithesh Kozhipurath

Ranch Hand

Posts: 76

posted 10 years ago

The JSF can work similar to a Servelet. You can specify the navigation rules in the faces-cofig.xml In this xml file you can specify the navigation case and outcome value and to view id. Using this outcome value you could navigate to different pages. The value in this outcome field can be a scope variable. This can done using the #{} construct.

I m not very sure that this will satisfy the req. Please try.

Jithesh K

Richard Green

Ranch Hand

Posts: 536

posted 10 years ago

anyone?

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)

Brian Smith

Ranch Hand

Posts: 63

posted 10 years ago

Just like Jithesh said, navigation is handled in the faces-config.xml file. When you preform an action on a page by clicking a link/button whatever, you define a navigation rule in the faces-config. That navigation rule is set to forward by default but can be set to redirect explicitly. Here is a link to the book Core JavaServer Faces. Quite a few chapters are available for free.