0

I'm using JSF 2.0. Is there anyway to call a javascript function after a bean method? Something like

<h:commandLink oncomplete="pop()" action="#{bean.method}"/>

I tried oncomplete, but doesn't work.

Nacho321
  • 1,911
  • 7
  • 33
  • 55
  • Maybe [this link](http://stackoverflow.com/questions/5719336/jsf2-execute-javascript-after-every-postback) can help you... Or if you have a small function you could write the full code in `oncomplete` attribute. – danRod Sep 19 '13 at 22:54

1 Answers1

3

I've found a way.

<h:commandLink action="#{bean.method}">
  <f:ajax onevent="pop"/>
</h:commandLink>

<script type="text/javascript">
    function pop(data){
        if(data.status == "success"){
           ....
        }
    }
</script>

There are probably better ways, so if you have a better solution, feel free to leave your answer!

Nacho321
  • 1,911
  • 7
  • 33
  • 55