【问题标题】:How to delay a commandLink in jsf with javascript or primefaces?如何使用javascript或primefaces延迟jsf中的commandLink?
【发布时间】:2014-04-04 22:58:57
【问题描述】:

我有一个调用后端页面 bean 方法的 commandLink。但我想在它调用该方法之前延迟一下。如何使用 javascipt 或 primefaces 做到这一点?

【问题讨论】:

标签: javascript jsf primefaces commandlink


【解决方案1】:

PrimeFaces 提供p:remoteCommand。它可以通过 javascript 调用并执行、执行操作和 ajax 处理和更新。使用p:commandLink 调用带有timeout 的javascript 函数。总之

<p:commandLink onclick="delayIt()" />

<p:remoteCommand name="remoteCommandName" ... action ... update ... process/>


<script type="text/javascript">
    var delayIt = function(){
       setTimeout( remoteCommandName,5000) //don't write () as it would execute it immediately
    }
</script>

【讨论】:

    【解决方案2】:

    在 primefaces 中尝试将“延迟”作为属性。 delay 默认为 null。

    <p:commandLink id="clid" actionListener="#{buttonView.buttonAction}" delay="1000">
        <h:outputText value="text" />
    </p:commandLink>
    

    【讨论】:

      猜你喜欢
      • 2016-10-13
      • 2013-12-29
      • 2012-10-01
      • 1970-01-01
      • 2013-05-22
      • 2014-01-19
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      相关资源
      最近更新 更多