* @param isFlash
* true when flash shall be enabled
*/
public void redirect(String url, boolean enableFlashback) {
if (url == null) {
throw new YFacesException("No URL specified", new NullPointerException());
}
final FacesContext fctx = FacesContext.getCurrentInstance();
final ExternalContext ectx = fctx.getExternalContext();
// when url is not absolute...
if (!url.startsWith("http")) {
// spec. accepts absolute as well as relative url
// relative path without leading slash is interpreted relatively to
// current request URI
// relative path with leading slash is interpreted relatively to
// context root
// but here a leading slash is interpreted relatively to
// webapplication root
if (url.startsWith("/")) {
url = ectx.getRequestContextPath() + url;
}
}
log.info("Redirecting to " + url);
try {
ectx.redirect(ectx.encodeResourceURL(url));
fctx.responseComplete();
} catch (IOException e) {
throw new YFacesException("Can't redirect to " + url, e);
}
//this.setFlash(isFlash);
if (enableFlashback) {
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(
IS_FLASHBACK, Boolean.TRUE);