Discussions
Web tier: servlets, JSP, Web frameworks: JSF - external link - controller decides to dispatch to a page?
-
JSF - external link - controller decides to dispatch to a page? (2 messages)
- Posted by: Walter Angerer
- Posted on: January 24 2008 06:17 EST
Hi, I have a JSF question. I have an external link, for example: http://localhost:9001/storefoundation/pages/resetPassword.jsf?resetPasswordKey=fea5aea0-1d48-40ee-a5e3-7858dc8cf5b5 After clicking on this link I want to decide to dispatch to a form or if the key is wrong to a page complaining about the key. How can I do this with JSF? In the moment always the form is displayed. Kind regards, WalterThreaded Messages (2)
- Re: JSF - external link - controller decides to dispatch to a page? by Anil Kumar Sadineni on January 28 2008 12:31 EST
- A programmatic way by Lance L on February 01 2008 12:20 EST
-
Re: JSF - external link - controller decides to dispatch to a page?[ Go to top ]
- Posted by: Anil Kumar Sadineni
- Posted on: January 28 2008 12:31 EST
- in response to Walter Angerer
What does it mean by external link? Isn't this link points to JSF app? Anil. -
A programmatic way[ Go to top ]
- Posted by: Lance L
- Posted on: February 01 2008 12:20 EST
- in response to Walter Angerer
from an action handler of your managed bean. you can call. /** * Forward inside the jsf app * @param viewId a faces view id ( like /somepath/apage.jsp or /somepath/apage.xhtml) */ void forward(String viewId) { FacesContext facesContext = FacesContext.getCurrentInstance(); String currentViewId = facesContext.getViewRoot().getViewId(); if (viewId != null && (!viewId.equals(currentViewId))) { ViewHandler viewHandler = facesContext.getApplication() .getViewHandler(); UIViewRoot viewRoot = viewHandler.createView(facesContext, viewId); facesContext.setViewRoot(viewRoot); facesContext.renderResponse(); } } /** * Redirect to a new url * @param url an external url */ void redirect(String url) throws IOException{ FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalCtx = facesContext.getExternalContext(); externalCtx.redirect( url); }