Javaメソッドからページを他のページにリダイレクトする方法はありますか?
私はそれを使用して転送することしかできません:
FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml");
または のナビゲーション ルールを使用しfaces-config.xml
ます。
あなたはなにか考えはありますか?
Javaメソッドからページを他のページにリダイレクトする方法はありますか?
私はそれを使用して転送することしかできません:
FacesContext.getCurrentInstance().getExternalContext().dispatch("/foo.xhtml");
または のナビゲーション ルールを使用しfaces-config.xml
ます。
あなたはなにか考えはありますか?
何を求めているのかわかりませんがExternalContext#dispatch()
、リダイレクトではなく転送のみを行います。ExternalContext#redirect()
代わりに使用したいと思います。
externalContext.redirect("foo.xhtml");
または外部(ディスパッチでは不可能)
externalContext.redirect("http://stackoverflow.com");
通常は、Bean のアクション メソッドでこれを行います。
コメントで JavaScript について言及したので、JS を使用してリダイレクトする方法は次のとおりです。
window.location = "foo.xhtml";
// Or
window.location = "http://stackoverflow.com";
FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation(FacesContext.getCurrentInstance(), null, "page.xhtml");
Works just as well.