JSF导航使用AjaxJSF、Ajax

2023-09-10 14:21:03 作者:菇凉,你何必楚楚可怜

如果我的地方,例如,下面的组件,点击它,它表现为预期的:

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.