0

I have a commandLink which calls a backend page bean method. but I want to make a delay before it calls that method. How to do this using javascipt or primefaces?

Imran Khurram
  • 377
  • 8
  • 18
  • have a look on [primefaces keyup event delay](http://stackoverflow.com/questions/8401218/primefaces-keyup-event-delay) . – Wanna Coffee Mar 03 '14 at 19:14

2 Answers2

1

PrimeFaces offers p:remoteCommand. It can be called via javascript and execute, do action and ajax process and updates. Use the p:commandLink to call a javascript function with a timeout. 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>
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
dsuess
  • 5,219
  • 2
  • 22
  • 22
1

In primefaces try 'delay' as attribute. delay is null as default.

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