template.xhtml

Agregamos al template funciones java script que actualizaran los componentes.

En este caso colocamos el ultimo mensaje

Actualizamos las etiquetas e invocamos el <:remotecommand>

      <script type="text/javascript">
            function socketListener(message, channel, event) {

                document.getElementById("websocketidTopText").innerHTML = message;
                document.getElementById("websocketidTopText2").innerHTML = message;

                myFormRC();
                waitForLoad();
                
             
                
            }
        </script>  

        <script name="jquery/jquery.js" library="primefaces" target="head" ></script>

Agregamos un <h:form> con el componente Websocket

<h:form>
    <f:websocket channel="clock" onmessage="socketListener" />        
</h:form>

Código completo

Last updated

Was this helpful?