dev@javaserverfaces.java.net

Re: Form w/ PrependId = False and findComponent

From: Adam Winer <adam.winer_at_oracle.com>
Date: Wed, 01 Feb 2006 09:27:38 -0800

Jacob,

findComponent() has nothing to do with clientId, despite
the similarity in syntax: it's strictly about searching
through NamingContainers. prependId deals strictly with
how clientIds are generated.

-- Adam


Jacob Hookom wrote:
> 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
> }
>