code: public static FormInfo findNestingForm(UIComponent uiComponent,
              FacesContext facesContext)
      {
          UIComponent parent = uiComponent.getParent();
          while (parent != null
                  && (!ADF_FORM_COMPONENT_FAMILY.equals(parent.getFamily())
                          && !TRINIDAD_FORM_COMPONENT_FAMILY.equals(parent
                                  .getFamily()) && !(parent instanceof UIForm)))
          {
              parent = parent.getParent();
          }
  
          if (parent != null)
          {
              //link is nested inside a form
              String formName = parent.getClientId(facesContext);
              return new FormInfo(parent, formName);
          }
  
          return null;
      }
docs: Find the enclosing form of a component
  in the view-tree.
  All Subclasses of <code>UIForm</code> and all known
  form-families are searched for.
  Currently those are the Trinidad form family,
  and the (old) ADF Faces form family.
  <p/>
  There might be additional form families
  which have to be explicitly entered here.
  
  @param uiComponent
  @param facesContext
  @return FormInfo Information about the form - the form itself and its name.