Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to redirect in a jsf?

 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone?
 
Brian Smith
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

http://www.horstmann.com/corejsf/

Here is the chapter on navigation
http://www.phptr.com/articles/printerfriendly.asp?p=353551&rl=1

Toward the end of the chapter, they talk about redirects
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic