title: How do I break the tyranny of the clientID?
body: <p>My least favorite part of coding JSF 2.0 forms has to do with the handing of the <strong>id</strong> attributes of the various input elements.  I am forever having trouble coding the clientID of the target component from within the backing bean, particularly since PrimeFaces <strong>tabView</strong> now includes the id of the <strong>p:tab</strong> element as part of the clientID.   I waste tons of time coding, testing, then re-coding those clientIDs.</p>
  
  <p>It is reminiscent of older-style assembly language programming where you have to generate tons of label names for your branches and loops.  I've done of enough of that for a lifetime.</p>
  
  <p>One approach I am trying is to use only auto-generated <strong>id</strong> attributes.  For example one line of my form might look like this.</p>
  
  <pre><code>&lt;h:outputLabel value="Full Name:" /&gt;
  &lt;p:inputText value="#{editUser.user.fullName}"
               binding="#{editUser.compFullName}"/&gt;
  &lt;p:message for="#{editUser.compFullName.clientId}" /&gt;
  </code></pre>
  
  <p>Note that I do not have an explicit <strong>id</strong> attribute.  Then in the backing bean:</p>
  
  <pre><code>    String clientID = getCompFullName().getClientId();
      msg = new FacesMessage(FacesMessage.SEVERITY_INFO, 
              "Summary Message For Full Name", "Detail Message Full Name");
      FacesContext.getCurrentInstance().addMessage(clientID, msg);
  </code></pre>
  
  <p>This always works, even if the component has a complex clientID, such as when PrimeFaces inserts the <strong>p:tab</strong> id into the clientID.  (Which it does starting v 3).  Rearranging the form never breaks anything.</p>
  
  <p>It is, however, laborious, since I have to create UIComponent properties, getters and setters, and bind them in the form with <strong>binding</strong> attributes.  Can anyone suggest a better way of doing this?</p>