title: Setting focus of input text in a loop
body: <p>I need to set focus to an h:inputText which is in a component like this: </p>
  
  <pre><code>    &lt;h:panelGroup id="bidView"&gt;
          &lt;h:panelGroup rendered="#{some conditions}"&gt;            
              &lt;h:outputText&gt;
              Some text&lt;/h:outputText&gt;                
              &lt;p:inputText id="amountInput" value="#{bean.bidAmount}" /&gt;
              &lt;h:commandButton value="Submit"&gt;
                  &lt;f:ajax listener="#{bean.submit(item)}" execute="@form" render="bidView "/&gt;
              &lt;/h:commandButton&gt;
          &lt;/h:panelGroup&gt;
              &lt;script&gt;document.getElementById('amountInput').focus()&lt;/script&gt;
  
      &lt;/h:panelGroup&gt;
  </code></pre>
  
  <p>The input text that needs to get the focus is "amountInput." The javascript code I was thinking should do it is </p>
  
  <pre><code>&lt;script&gt;document.getElementById('amountInput').focus()
  </code></pre>
  
  <p>but it generates the following error: "Cannon call method 'focus' of null." What am I missing? </p>
  
  <p>(I should add that bidView is rendered when the user clicks a Submit button next to each row inside a table. It, bidView, then shows up under that clicked row and allows the user to enter a number and have the server process it.)</p>