【问题标题】:Primefaces p:ajax listener conditional updatePrimefaces p:ajax 监听器条件更新
【发布时间】:2015-03-17 07:03:25
【问题描述】:

JSF 页面:

<p:commandButton>
  <p:ajax process="@this" update="name desc msg"
    listener="#{bean.deleteListener}"/>
</p:commandButton>

豆子:

public void deleteListener() {
  if (data.size() == 0) {
    // updates only "msg"
    setMsg("There is no data to delete");
    return;
  }
  setMsg("Data deleted.");
  // and updates the bean values for "name" and "desc" also.
  ...
}

是否可以根据 ajax 侦听器逻辑有条件地更新 ajax 调用。我想有条件地更新客户端 ID“name desc msg”,如下面的侦听器代码所示(注意这是更大应用程序中的示例场景)。该应用程序使用 Primefaces 5。谢谢。

【问题讨论】:

    标签: ajax primefaces


    【解决方案1】:

    当然,在你的监听器中使用 PrimeFaces RequestContext

    RequestContext context = RequestContext.getCurrentInstance();
    
    //update panel
    context.update("form:panel");
    

    另请参阅: - http://www.primefaces.org/showcase/ui/misc/requestContext.xhtml

    【讨论】:

      猜你喜欢
      • 2013-12-22
      • 2014-05-08
      • 2012-03-20
      • 2013-02-04
      • 2012-05-08
      • 2014-12-10
      • 1970-01-01
      • 2011-08-20
      • 2014-12-21
      相关资源
      最近更新 更多