wood burning stoves*
The moose likes JSF and the fly likes Trying to redirect from page user has clicked on to another (might be able to use nav rule?) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Trying to redirect from page user has clicked on to another (might be able to use nav rule?)" Watch "Trying to redirect from page user has clicked on to another (might be able to use nav rule?)" New topic
Author

Trying to redirect from page user has clicked on to another (might be able to use nav rule?)

Matt Kohanek
Village Idiot
Ranch Hand

Joined: Apr 04, 2009
Posts: 483

Hi

Let's say a user gets an email with a url. I need that url to send the user to a page that triggers some java backing bean action, and regardless of that out come, the user is then redirected to another page.

I have the logic in place to send the user to the page in the email (user clicking the link I suppose...) and do the backing bean actions (<h:form id="Form" name="Form" class="Form" binding="#{InitBean.form}"> ), but I am not sure what is best to use to then send the user to another url once the actions have been triggered in the Init bean.

I was considering something like this:




Will this do what I need (I cannot test it just yet, waiting for deploys so I do not want to mess with checked in code)?
And even if it will, is this the best way to accomplish this?


True wisdom is in knowing you know nothing - Socrates
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

JSF navigation is used when a JSF view has fired off an action and the action then wishes to tell JSF what JSF view to present as a response. Which in and of itself isn't actually a "redirect".

Navigation only applies to JSF views, however, so if you want the response to be rendered from non-JSF resources such as servlets, JSPs, or even plain old HTML, you will have to do a true redirect. There's no simple JSF method for that, so you have to do it the hard way: get the FacesContext, use it to obtain the raw J2EE components, then do a traditional redirect using them.

More commonly, I present a JSF response view that contains a link that references whatever non-JSF function I need, since usually I'm doing something that includes user interaction in the process.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trying to redirect from page user has clicked on to another (might be able to use nav rule?)
 
Similar Threads
Clearing Form on "success" outcome
How to create a secure login system?
Navigation Problem
Binding: converting from String to Object
Trouble passing request params to redirect in navigation rule