Javascript Does not execute . click correctly with JSF

Asked

Viewed 22 times

-1

The script works partially, it updates the page after 5 sec., however it does not perform the click on the button:

<script>
$(document).ready(function() {
      setInterval(function() {
        cache_clear()
      }, 5000);
});

function cache_clear() {
    document.getElementById('listTab:teste').click();
    window.location.reload(true);
}

My form (.xhtml):

<h:form id="listTab">
  <p:panelGrid>
    <p:commandButton value="Atualizar Tabela" class="btn btn-block btn-success" ajax="false" actionListener="#{chamadoBean.teste()}" id="teste"/>
  </p:panelGrid>
</h:form>

My Bean:

public void teste() {
   System.out.println("teste");
}

It shows nothing on the console after the page refreshes, so the button is not clicked. Some other way to do this?

1 answer

0

Well, I managed to solve using socket.

<o:socket channel="clock" onmessage="socketListener" >
   <f:ajax event="someEvent" listener="#{chamadoBean.listaChamado()}" render=":tblLista" />
</o:socket>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.