Ok. I think I see....here's my understanding of the issue; please correct me if I've misinterpreted.
The problem is when you've got an id of form "form:table:3:component", eg received via an ajax call. Just adding a colon to the front forms an absolute path that findComponent can use to locate that component by tracing from the UIViewRoot down, yes? However the "row" bit in the middle is a problem. The findComponent method will fail, looking for a component of id "3". Even if it does recognise that "table" is a UIData, steps into it, finds the child component, then returns it the problem remains that you've got a reference to a component but can't call it because its "state" does not reflect the row it's on. If findComponent were to call setRowIndex on the UIData component, that would work, but would potentially stuff up the UIData's current state for other purposes. An "executeOnComponent" that works like findComponent but takes a "callback" does sound useful here. It walks the component tree like findComponent, detecting UIData components, saving their current rowIndex and setting it to the provided index from the path. When the component is finally found, the callback is executed passing the component. On completion, the find process is then unwound, restoring any UIData components to their original rowIndex. It does sound a little fragile, though. It means treating UIData components specially which I don't like. Any use of "instanceof" in an OO program is a warning sign. Or can the UIData override findComponent on itself to manage that transparently? If so, that would be nice. Possibly non-portable though. Or did you mean something else?? Cheers, Simon On Fri, 2006-01-20 at 12:24 +0100, Martin Marinschek wrote: > Example 1: try to use an input-field in your data-table, and look at > the output of the <h:messages> - the messages won't indicate the row > of the component in the dataTable - they can't, due to this problem. > > Example 2: try to use the new AJAX-form components (which rely on the > usage of find-component heavily) in a dataTable. > > regards, > > Martin > > On 1/20/06, Simon Kitching <[EMAIL PROTECTED]> wrote: > > On Fri, 2006-01-20 at 11:57 +0100, Martin Marinschek wrote: > > > Hi *, > > > > > > I am having the following problem: > > > > > > whenever I use dataTables > > > > > > - and use messages alongside, or AJAX, or other stuff using findComponent > > > - > > > > > > I have the problem that I can't work with the components that are > > > children of the dataTables if I call a findComponent. Of course - I > > > won't find the correct component instance, due to the generated id and > > > the things the dataTable is doing to set the context of the current > > > row. > > > > > > I've been thinking of a solution to this problem, and the only > > > solution that has come to my mind is to get rid of findComponent for > > > such things - and create an "executeOnComponent" method, which can be > > > implemented by all components doing special things with their > > > children. > > > > > > I believe that components are too much of a black box for > > > findComponent ever to work at all - what's your impression? > > > > > > Thoughts? feedback? Better ideas ;) ? > > > > I've found findComponent very useful (once I figured out what it does; > > the sun-provided documenation really sucked). > > > > Of course I've never had the need for a component to "find" another > > component that is nested inside a table. > > > > I don't understand your "executeOnComponent" suggestion. Could you give > > an example? > > > > Regards, > > > > Simon > > > > > > > -- > > http://www.irian.at > > Your JSF powerhouse - > JSF Consulting, Development and > Courses in English and German > > Professional Support for Apache MyFaces
