Mario Ivankovits wrote:
Hi Dean!
but, unfortunately, I have to query another service for the URL to
really redirect to!!!  This means, I can't put the URL in the
faces-config.xml file.  Is there any way to do any of these options(or
others....list is not exhaustive probably)
I am not definitely sure, but maybe a navigation handler could help.

*) create a class which extends from
"javax.faces.application.NavigationHandler"
*) create a constructor which takes one parameter which is also a
NavigationHandler - we call it originalHandler
*) override handleNavigation
*) configure this class in your faces-config.xml
*) if the fromAction is a url (e.g. starts with http://) get the
externalContext/response object - cast it to httpServletresponse and
*) call sendRedirect (or so, cant remember now)
*) else call originalHandler.handleNavigation

Note that you can achieve the same thing in your backing bean action, without having to install a view handler. The trick is to tell JSF you've handled the response so it skips generating one. Something like this:

  public String myAction() {
    String url = getMyUrl();
    FacesContext ctx = FacesContext.getCurrentInstance();
    ctx.getExternalContext().redirect(url);
    ctx.responseComplete();
    return null;
  }

L.

Reply via email to