【问题标题】:JSF Ajax Navigation timeoutJSF Ajax 导航超时
【发布时间】:2013-02-25 23:07:27
【问题描述】:

我正在使用 selectonemenu 结合 ajax 进行导航。

JSF 代码

<p:selectOneMenu value="#{navigator.outcome}">                      
    <f:selectItem itemLabel="Select page..." />
    <f:selectItem itemValue="page1" itemLabel="Page 1" />
    <f:selectItem itemValue="page2" itemLabel="Page 2" />
    <f:selectItem itemValue="page3" itemLabel="Page 3" />
    <p:ajax event="change" listener="#{navigator.navigate}" />
</p:selectOneMenu>

托管 bean:

public void navigate() {
    FacesContext context = FacesContext.getCurrentInstance();
     NavigationHandler navigationHandler = context.getApplication()
            .getNavigationHandler();

    navigationHandler.handleNavigation(context, null, outcome
            + "?faces-redirect=true");
}

我有一个问题,如果我让页面打开很长时间(可能是几个小时),ajax 导航似乎停止工作。是否存在某种超时?

【问题讨论】:

  • 会话超时。而且不仅是 ajax 请求,在您重新访问该页面之前,每种类型的请求都会失效。
  • 您是如何应对这种情况的?表单提交也不起作用吗?
  • 如果您在上一个问题上使用此答案中提出的方法,则会出现此问题:stackoverflow.com/questions/15008487/…
  • 我无法使用它,因为我需要它使用原生
  • @BalusC 超时问题只发生在 Ajax 上吗?如果我有一个提交按钮,那会起作用吗?

标签: ajax jsf navigation timeout


【解决方案1】:

不要使用 ajax 导航,而是使用以下内容:

<p:selectOneMenu value="#{navigator.outcome}" onchange="window.location =this.options[this.selectedIndex].value">                      
    <f:selectItem itemLabel="Select page..." />
    <f:selectItem itemValue="page1" itemLabel="Page 1" />
    <f:selectItem itemValue="page2" itemLabel="Page 2" />
    <f:selectItem itemValue="page3" itemLabel="Page 3" />

</p:selectOneMenu>

即使会话超时,这仍然有效。

【讨论】:

    猜你喜欢
    • 2011-09-29
    • 2011-07-21
    • 1970-01-01
    • 1970-01-01
    • 2021-07-24
    • 2011-11-22
    • 2013-01-22
    • 2011-11-03
    • 1970-01-01
    相关资源
    最近更新 更多