如何同时使用导航规则和f:阿贾克斯规则、阿贾克斯

2023-09-10 17:55:37 作者:芡念

下面是我的情况:我想更新通过Ajax的网页在某些情况下,在其他情况下,执行导航规则。我用例是登录表单。我希望他们通过AJAX,如果他们的uname /密码,没有收到一个错误消息,但导航到一个新的页面,如果它成功了。

Here's my scenario: I'd like to update a page via Ajax in some cases, in other cases, execute a navigation rule. My use case is a login form. I'd like them to receive an error message via ajax if their uname/password fails, but navigate to a new page if it succeeds.

有没有人做到了这一点使用JSF2.0 F:AJAX API的?我不是在走标准的小面,JSF2.0等之外的解决方案很感兴趣。

Has anyone done this using JSF2.0 f:ajax apis? I'm not really interested in solutions that go outside standard facelets, jsf2.0, etc.

推荐答案

这是从做时,它没有Ajax没有什么不同。刚刚返回下一个视图ID为字符串通常的方式。

It's not different from when doing it without ajax. Just return the next view ID as String the usual way.

所以,只要

<h:commandButton value="Login" action="#{bean.login}">
    <f:ajax execute="@form" render="@form" />
</h:commandButton>

public String login() {
    // ...

    return "nextpage";
}

将工作不如无&LT; F:AJAX&GT; 。这将只是去 nextpage.xhtml