2 Replies Latest reply on May 7, 2010 2:40 PM by Matthew Pickell

    findComponent inside HtmlForm

    Marcelo Leiras Newbie

      Hi,

      I'm having problems to find components inside a HtmlForm. My code:

      <h:form id="formFind">
      <a4j:commandButton id="cbFind" value="find" actionListener="#{testForm.findButtonClicked}" />
      </h:form>
      
      <rich:panel id="pnA">
       <rich:panel id="pnB">
       <h:form id="formC">
       <rich:panel id="pnD">
       </rich:panel>
       </h:form>
       </rich:panel>
      </rich:panel>
      


      public void findButtonClicked(ActionEvent event) throws Exception {
       HtmlPanel pnA = (HtmlPanel)FacesContext.getCurrentInstance().getViewRoot().findComponent("pnA");
       System.out.println("\n>>>"+pnA.findComponent("pnD").getId()+"\n");
       }
      


      When i look for "formC" id, it works wright. But, if i look for "pnD", i have a Null Pointer exception, because pnA.findComponent("pnD") returns null. Why?