title: Get primefaces widgetVar in javascript and update it
body: <p>I have a primefaces component like this:</p>
  
  <pre><code>&lt;p:panel styleClass="errorsPanelClass" id="errorsPanel" header="Messages" toggleable="true" effect="drop" toggleSpeed="0" closeSpeed="0" widgetVar="errorsPanelWidget"&gt;
  </code></pre>
  
  <p>and i'm trying to get the component in javascript context and update it.</p>
  
  <p>I already tried with:</p>
  
  <pre><code>function getWidgetVarById(id) {
     for (var propertyName in PrimeFaces.widgets) {
       if (PrimeFaces.widgets[propertyName].id === id) {
         return PrimeFaces.widgets[propertyName];
       }
     }
  }
  </code></pre>
  
  <p>or</p>
  
  <p><a href="https://stackoverflow.com/questions/17370915/how-to-find-a-widgetvar">How to find a widgetVar?</a></p>
  
  <p>or</p>
  
  <p><a href="https://stackoverflow.com/questions/11427647/get-widgetvar-with-javascript-or-check-uncheck-all-other-primefaces-checkboxes">Get widgetVar with JavaScript or check/uncheck all other PrimeFaces checkboxes</a></p>
  
  <p>It will be great if I'll find a solution to take the widgetVar by class, but any other solutions are welcomed.</p>
  
  <p>I also tried:</p>
  
  <pre><code>function getWidgetVarById() {
      for ( var propertyName in PrimeFaces.widgets) {
          alert(PrimeFaces.widgets[propertyName].id);
      }
  }
  </code></pre>
  
  <p>but I get an javascript error "'PrimeFaces.widgets.length' is null or not an object"</p>
  
  <p>Any ideas?</p>