문제

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?

도움이 되었습니까?

해결책

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>

다른 팁

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top