0

I'm trying to click a button after the page loading to open a pop up window with some information:

<script type="text/javascript">
        function doHiddenClickPuntoAgua() {
            document.getElementById("form:puntoAgua").click();
        }
</script>

<p:commandButton id="puntoAgua"
        actionListener="#{viewGestionBean.openDialogAgua()}"
        style="display: none;">
        <p:ajax event="dialogReturn"
            listener="#{gestionBean.actualizaTabla()}"
            update=":form:tablaUbicaciones" />
    </p:commandButton>

I see that the function is calling from then backbean but the actionListener not working in my command button why?

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • Does this answer your question? [How to invoke a JSF managed bean on a HTML DOM event using native JavaScript?](https://stackoverflow.com/questions/16588327/how-to-invoke-a-jsf-managed-bean-on-a-html-dom-event-using-native-javascript) – Jasper de Vries Mar 18 '21 at 16:07
  • See https://www.primefaces.org/showcase/ui/ajax/remoteCommand.xhtml?jfwid=47455 – Jasper de Vries Mar 18 '21 at 16:07

1 Answers1

-1

your DOM selector is not referencing the target correctly, try

function doHiddenClickPuntoAgua() {
    document.getElementById("puntoAgua").click();
}
doHiddenClickPuntoAgua()
JC ONG
  • 89
  • 7