使用 Ajax 进行 JSF 导航

2022-01-10 00:00:00 navigation ajax jsf-2

例如,如果我放置以下组件并单击它,它将按预期运行:

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

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

但如果我使用 Ajax:

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?

另一个问题是,当我在会话超时后单击使用 ajax 的按钮时,应用程序会重定向到登录页面,但它不会加载 css 文件.

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.

有什么想法吗?

亲切的问候,

卡洛斯·费雷拉

推荐答案

如果您发送重定向,您可以做到.

You can do it if you send a redirect.

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

但是,我完全看不到像这样使用 Ajax 进行导航的意义/好处.

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

相关文章