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?
Asked
Active
Viewed 2,749 times
0
-
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 Answers
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>
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