# template.xhtml

Agregamos al template funciones java script que actualizaran los componentes.&#x20;

En este caso colocamos el ultimo mensaje

Actualizamos las etiquetas e invocamos el <:remotecommand>&#x20;

```markup
      <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

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

### Código completo

```markup
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:b="http://bootsfaces.net/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"

      xmlns:jmoordbjsf="http://jmoordbjsf.com/taglib">
    <h:head>
        <f:facet name="first">
            <f:view locale="#{jmoordbLanguajes.locale !=null?jmoordbLanguajes.locale:'es'}"></f:view>
            <f:loadBundle basename="com.properties.messages" var="msg" />
            <f:loadBundle basename="com.jmoordbutils.properties.application" var="app" />

        </f:facet>
        <title>#{msg['application.shorttitle']}</title>
        <meta name="author" content="Aristides Villarreal" />
        <meta name="description" content="BootsFaces, a powerful JSF framework that takes the best from Bootstrap and jQuery UI to let develop well-designed state-of-the-art next-gen Front-end Enterprise Applications fast and easy supporting HTML5." />
        <meta name="KEYWORDS" content="jsf, bootstrap, framework, java, enterprise, server, faces, jquery, usability, next-gen, web, html5, easy, modern, well-designed, website, state-of-the-art" />
        <meta name="robots" content="index, follow" />


        <jmoordbjsf:metatemplate/>
        <jmoordbjsf:csstemplate/>
        <style>.tooltip-inner {
                max-width: 350px;
                /* If max-width does not work, try using width instead */
                width: 350px; 
            }</style>

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

                document.getElementById("websocketid_topText").innerHTML = message;
                document.getElementById("websocketid_topText2").innerHTML = message;
             
            }
        </script>  
    </h:head>
    <h:body style="padding-top: 85px;padding-bottom: 85px;" >

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

        <ui:insert name="nbtop">

            <ui:include src="/layout/top.xhtml"/>
        </ui:insert>

        <b:container >
            <ui:insert name="content"/>
        </b:container>

        <ui:insert name="nbtop">
            <ui:include src="/layout/footer.xhtml"/>
        </ui:insert>

    </h:body>
</html>

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/trucosjakartaee/web-socket/websocket/websocket-en-menu/template.xhtml.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
