dev@javaserverfaces.java.net

Form w/ PrependId = False and findComponent

From: Jacob Hookom <jacob_at_hookom.net>
Date: Wed, 01 Feb 2006 01:51:44 -0600

the findComponent(UIComponent base, String id) pre-parses the clientId
and carries the expectation that the NamingContainer will always prefix.

<h:form id="fooForm" prependId="false">
   <h:inputText id="fooText" ... />
</h:form>

UIViewRoot.findComponent(":fooText") -> null

I agree that using the ":" should start from the root of the tree, but
the UIComponentBase should *not* dictate naming behavior around its
children implementing NamingContainer.

It should work something like:

findComponent(String id) {
  // if prefix, start from root and pass substring
  if (id == myclientid) { return this; }
  Iterator itr = this.getFacetsAndChildren();
  while (itr.hasNext()) {
     uic = itr.next().findComponent(id);
     if (uic != null) return uic;
  }
  return null;
}

// UIForm

findComponent(String id) {
  if (id == myclientid) { return this; }
  if (prependId && !id.startswith(myclientId)) { return null; }
  return super.findComponent(id);
}

// UIData

findComponent(String id) {
  if (id == myclientid) { return this; }
  if (id.startswith(myclientid)) id = id.removeindex
  else return null;
  this.setRow(index);
  return super.findComponent(id);
  // possibly set orig rowindex
}

-- 
Jacob Hookom  -  Minneapolis
----------------------------
JSF-EG, JSF-RI, EL, Facelets