I don't quote follow your description of the problem below. However if
you want to reference a component in a nested naming container, then you
can just provide the appropriate path:
"somesubview:targetId"
A naming container is equivalent to a directory, and an id passed to
findComponent is equivalent to a filename; think of ":" as "/" (or
backslash for you windows users).
When searching for a file, if the filename is in the "current working
directory", then you need no dirname; if it is in a subdir then you need
to include the path relative to the current working dir, and if you are
searching from the root dir then you need the absolute path.
Alternatively, you can always provide the absolute path.
Searching for components by id is exactly the same, where the equivalent
of "the working directory" is whatever naming container encloses the
component you invoke the find method on. Pass a relative path, or pass
an absolute path.
Writing a search that ignores naming container structure is equivalent
to having a filesystem that can be searched for "foo.txt", and returns
it no matter where it resides in the filesystem - good until *two*
foo.txt files exist in the filesystem at which point everything gets ugly.
BTW, this is also why the myfaces "forceId" attribute sucks. This isn't
relevant to your situation, though, as you are dealing with ids, while
forceid is an attempt to address an equivalent issue with client-ids.
Regards,
Simon
Tom Innes wrote:
Sorry this is not a bug after all. The findComponent by specification in
_ComponentUtils will not search any descendant NamingContainers. Since
HTMLPanelTab is a Naming Container it will not search the components
contained within.
I guess I will have to write my own search algorithm that will.
Tom
-----Original Message-----
From: Tom Innes [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 18, 2007 2:55 PM
To: 'MyFaces Discussion'
Subject: Possible Bug with UIComponentBases findComponent Method and
TabbedPanels
I downloaded the latest snapshot for myfaces 1.1.5 and tomahawk yesterday (
Jan 17 ) and I am noticing a problem when using <t:panelTabbedPane
I am using a slightly modified version of the Focus component in the
Sandbox. When It attempts to set the focus to a component on any tabbed
Panel I am getting an Illegal State Exception.
java.lang.IllegalStateException: AFocus: findUIComponent() - could not find
UIComponent referenced by attribute for = |nameFieldId|
at
com.alltiers.arch.client.jsf.component.output.focus.AFocus.findUIComponent(A
Focus.java:65)
Basically the code that is being executed in AFocus's findUIComponent
method. AFocus extends UIComponentBase
UIComponent forComp = findComponent(forStr);
if (forComp == null) {
log.error("findUIComponent() - could not find
UIComponent referenced by attribute for = |" + forStr + "|");
// TODO - Put in for Development - Remove for
Production
// Don't Blow Up because you couldn't set Focus
// Debug What is in the Component Tree
AFacesUtility.debugForm();
throw new IllegalStateException("AFocus: findUIComponent() -
could not find UIComponent referenced by attribute for = |" + forStr + "|");
}
I placed debugging code in the method and was able to verify that the
component does exist.
14:32:20,656 INFO [STDOUT] Component id = nameLabelId Has 0 Children and is
of class javax.faces.component.html.HtmlOutputLabel
14:32:20,656 INFO [STDOUT] Component id = _id12 Has 1 Children and is of
class javax.faces.component.html.HtmlPanelGroup
14:32:20,656 INFO [STDOUT] ----------------- Displaying Children
-------------------
14:32:20,656 INFO [STDOUT] Component id = nameFieldId Has 0 Children and is
of class com.alltiers.arch.client.jsf.component.input.inputtext.AInputText
14:32:20,656 INFO [STDOUT] Component id = _id13 Has 1 Children and is of
class javax.faces.component.html.HtmlPanelGroup
14:32:20,656 INFO [STDOUT] ----------------- Displaying Children
-------------------
This code was working based on a previous snapshot of MyFaces and Tomahawk.
The code also works on any form that does not include a Tabbed Panel.
Anybody have any suggestions?
Tom