title: primefaces uiViewRoot find component inside <p:dataTable >
body: <p>I am using primefaces 3.2.</p>
  
  <p>I've got the following situation:</p>
  
  <pre><code>&lt;h:form id="someForm"&gt;
    ..
    &lt;p:dataTable id="someDataTable" value="#{BackingBean.list}" var="element" ..&gt;
      &lt;p:column&gt;
        &lt;p:calendar id="someCalendar" value=#{element.date} ../&gt;
        &lt;p:message id="someCalendarMessage" for=":someForm:someDataTable:someCalendar"/&gt;
      &lt;p:column&gt;
    &lt;/p:dataTable&gt;    
    ..
  &lt;/h:form&gt;
  </code></pre>
  
  <p>The  "someDataTable" is updated dynamically and then all the data are submitted to the server side. In the backing bean I want to send message for calendar "someCalendar" if the entered date doesn't satisfy some condition. I try to find the component using this code:</p>
  
  <pre><code>FacesContext facesContext = FacesContext.getCurrentInstance();
  facesContext.addMessage(facesContext.getViewRoot().findComponent(":someForm:someDataTable:" + "i" + ":someCalendar").getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, Utils.getResourceBundleString("dictionary", "error") + ":", Utils.getResourceBundleString("dictionary", "some_message")));
  return;
  </code></pre>
  
  <p>Where i is the index of the "element" in the dataTable which the same as index in the list located in the BackingBean.</p>
  
  <p>The problem is that I get NullPointerException since the facesContext.getViewRoot().findComponent(..) method cannot find the component, although I checked the generated id of the calendar in the view and it is 
  :someForm:someDataTable:0:someCalendar for the first element and it should be :someForm:someDataTable:1:someCalendar for the next element etc. </p>
  
  <p>Why the facesContext.getViewRoot().findComponent(..) method cannot find the component inside the ? The  is updated dynamically and maybe the server side doesn't get the updated component tree after submission is done?</p>
  
  <p>Thanks in advance.  </p>