如何从ManagedBean何时发送的请求是一个Ajax请求重定向? [英] How to redirect from a ManagedBean for when the request sent is an Ajax request?
问题描述
我使用PrimeFaces与JSF2。我试图通过发送登录名和密码作为一个Ajax请求,以验证用户。而在辅助bean的操作方法,我想验证用户重定向到一个新的观点,如果验证成功。
I am using PrimeFaces with JSF2. I am trying to authenticate user by sending login and password as an Ajax request. And in the action method of the backing bean, I am trying to validate user and redirect to a new view if the validation succeeds.
在使用primefaces这可能吗?
Is this possible while using primefaces?
由于我觉得跟primefaces号码:。的commandButton
,我只能要么AJAX行为或导航
Because I think with primefaces' p:commandButton
, I can only either have ajax behavior or the navigation.
推荐答案
是的,只是发送重定向,而不是一个(默认)向前结果。该<导航情况>
-less JSF 2.0的方式将被追加面临重定向= TRUE
的结局字符串的操作方法。
Yes, just send a redirect instead of a (default) forward as outcome. The <navigation-case>
-less JSF 2.0 way would be appending ?faces-redirect=true
to the outcome string in the action method.
例如。
public String login() {
// ...
return "home?faces-redirect=true";
}
这篇关于如何从ManagedBean何时发送的请求是一个Ajax请求重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!