title: xhtml + jsf get values from a controller class
body: <p>I want to ask you about how xhtml works.</p>
  
  <p>this is my tablero.xhtml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:c="http://java.sun.com/jsp/jstl/core"
        xmlns:p="http://primefaces.org/ui"&gt;
  
      &lt;ui:composition template="/template.xhtml"&gt;
          &lt;ui:define name="title"&gt;
              &lt;h:outputText value="Dak's Hangman"&gt;&lt;/h:outputText&gt;
          &lt;/ui:define&gt;
          &lt;ui:define name="body"&gt;
              &lt;h:panelGroup id="messagePanel" layout="block"&gt;
                  &lt;h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/&gt;
              &lt;/h:panelGroup&gt;
              &lt;h:head  id="demo" &gt;Opportunities: &lt;/h:head&gt;            
              &lt;h:outputText value="#{partidaController.getRemainingOp()}"/&gt;    
              &lt;br/&gt;
              &lt;h:outputText value="#{partidaController.getNombreJugador()}"/&gt;                   
              &lt;br/&gt;
              &lt;c:forEach var="x" items="#{partidaController.getLetrasColocadas()}" &gt;
                  &lt;h:inputText disabled="true" size="1" value="${x}"/&gt;
              &lt;/c:forEach&gt;
              &lt;br/&gt;
              &lt;h:panelGrid&gt;
                  &lt;h:form&gt;
                      &lt;p:commandButton id="b1" style="height: 30px; width: 30px;" value="a" action="#{turnoController.createTurno('a')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b2" style="height: 30px; width: 30px;" value="b" action="#{turnoController.createTurno('b')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b3" style="height: 30px; width: 30px;" value="c" action="#{turnoController.createTurno('c')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b4" style="height: 30px; width: 30px;" value="d" action="#{turnoController.createTurno('d')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b5" style="height: 30px; width: 30px;" value="e" action="#{turnoController.createTurno('e')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b6" style="height: 30px; width: 30px;" value="f" action="#{turnoController.createTurno('f')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b7" style="height: 30px; width: 30px;" value="g" action="#{turnoController.createTurno('g')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b8" style="height: 30px; width: 30px;" value="h" action="#{turnoController.createTurno('h')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b9" style="height: 30px; width: 30px;" value="i" action="#{turnoController.createTurno('i')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b10" style="height: 30px; width: 30px;" value="j" action="#{turnoController.createTurno('j')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b11" style="height: 30px; width: 30px;" value="k" action="#{turnoController.createTurno('k')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b12" style="height: 30px; width: 30px;" value="l" action="#{turnoController.createTurno('l')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b13" style="height: 30px; width: 30px;" value="m" action="#{turnoController.createTurno('m')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b14" style="height: 30px; width: 30px;" value="n" action="#{turnoController.createTurno('n')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b15" style="height: 30px; width: 30px;" value="o" action="#{turnoController.createTurno('o')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b16" style="height: 30px; width: 30px;" value="p" action="#{turnoController.createTurno('p')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b17" style="height: 30px; width: 30px;" value="q" action="#{turnoController.createTurno('q')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b18" style="height: 30px; width: 30px;" value="r" action="#{turnoController.createTurno('r')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b19" style="height: 30px; width: 30px;" value="s" action="#{turnoController.createTurno('s')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b20" style="height: 30px; width: 30px;" value="t" action="#{turnoController.createTurno('t')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b21" style="height: 30px; width: 30px;" value="u" action="#{turnoController.createTurno('u')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b22" style="height: 30px; width: 30px;" value="v" action="#{turnoController.createTurno('v')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b23" style="height: 30px; width: 30px;" value="w" action="#{turnoController.createTurno('w')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b24" style="height: 30px; width: 30px;" value="x" action="#{turnoController.createTurno('x')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b25" style="height: 30px; width: 30px;" value="y" action="#{turnoController.createTurno('y')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;p:commandButton id="b26" style="height: 30px; width: 30px;" value="z" action="#{turnoController.createTurno('z')}" onclick="document.getElementById(this.id).disabled=true;"/&gt;
                      &lt;br /&gt;
                  &lt;/h:form&gt;
              &lt;h:graphicImage value="../resources/images/hangman.jpg" width="480" height="400" /&gt;
              &lt;h:link outcome="/index" value="#{bundle.CreateJugadorIndexLink}"/&gt;        
          &lt;/h:panelGrid&gt;
          &lt;/ui:define&gt;
      &lt;/ui:composition&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is the bean I call every time I click the buttonCommand:</p>
  
  <pre><code>public String createTurno(String s) {
      try {
          Map&lt;String, Object&gt; sesionMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
          Integer id = (Integer) sesionMap.get("id_partida");
  
          Partida p = new Partida();
          p.setIdPartida(id);
          current= new Turno();
          current.setIdPartida(p);
          current.setLetraTurno(s);
          ejbFacade.create(current);
          return "tablero";
      } catch (Exception e) {
          JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
          return null;
      }
  }
  </code></pre>
  
  <p>and this is the method I want to call to update the items...</p>
  
  <pre><code>public List getLetrasColocadas()
  {
      String lc = getFacade().letrasColocadasById(current.getIdPartida());
  
      ArrayList&lt;String&gt; lista = new ArrayList&lt;String&gt;();
      int i;
      for (i=0; i&lt;lc.length(); i++){
          String h = "" + lc.charAt(i) + "";
          lista.add(h);
      }
      return lista;
  }
  </code></pre>
  
  <p>the partidaController.getLetrasColocadas() works fine (I have debugged it and it does what I want). The problem is that the the inputText values once they are shown, they never update again if a click a command button for example calling a bean which returns a string with the name of this xhtml file.... it always stays the same.</p>
  
  <p>Any magic I should know about xhtml???</p>