开发者

JSF Navigation with Ajax

If I place, for instance, the following component and click it, it behaves as expected:

<h:commandLink value="Click me" action="anotherPage.jsf" />

But if I use Ajax:

<h:commandLink value="Click me" action="anotherPage.jsf"><f:ajax /></h:commandLink>

It doesn't navigate to the other page. Am I missing something? Isn't this supposed to work?

Another issue is that, when I click a button that is using ajax after session timeout, the application redirects to the login page but it doesn't load css files.

Any ideas?

Kind re开发者_JAVA百科gards,

Carlos Ferreira


You can do it if you send a redirect.

action="anotherPage.jsf?faces-redirect=true"

However, I completely fail to see the point/benefit of navigating using Ajax like that.


From my understanding ajax is used to update components of the current page and not to navigate to other pages.


If you have lots of ajax requests on your page then ajaxifying the command button's request mean's that all other validations (from other ajax requests) on the page will complete before navigation to the next page. Otherwise without the ajax request for the button the http request that it generates will blow away these other requests and just navigate directly to the next page without waiting for them to complete.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜