简体   繁体   English

如何使用javascript或primefaces延迟jsf中的commandLink?

[英]How to delay a commandLink in jsf with javascript or primefaces?

I have a commandLink which calls a backend page bean method. 我有一个commandLink,它调用后端页面bean方法。 but I want to make a delay before it calls that method. 但我想在调用该方法之前进行延迟。 How to do this using javascipt or primefaces? 如何使用javascipt或primefaces执行此操作?

PrimeFaces offers p:remoteCommand . PrimeFaces提供了p:remoteCommand It can be called via javascript and execute, do action and ajax process and updates. 可以通过javascript调用它,并执行,执行操作以及ajax进程和更新。 Use the p:commandLink to call a javascript function with a timeout . 使用p:commandLink调用带有timeout功能的javascript函数。 In short 简而言之

<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>

In primefaces try 'delay' as attribute. 在素面中,尝试将“延迟”作为属性。 delay is null as default. delay默认为null。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM