myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <>
Subject Re: findComponent, dataTable, messages
Date Fri, 20 Jan 2006 14:10:10 GMT
> 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.
You can delegate this executeOnComponent to the component and thus each
component can implement its own strategy to find the requested child. So
no instanceof needed, though an addition to UIComponent (overriden by
Using a "boolean" return value to indicate the work has been done.
Something like the visitor pattern

So something like this (for sure, not jdk15 - I've done just do keep it

on UIComponent:

public boolean executeOnComponent(String id, ComponentExecutor process)
    if (id.equals(getId())
        return true;

    for (UIComponent component : components)
        if (component.executeOnComponent(id, process)
             return true;
    return false;

on UIData:

public boolean executeOnComponent(String id, ComponentExecutor process)
    for (int row : rows)
       // save the rowNum
       //skim through rows
            //set the rowNum
            // call executeOnComponent on each child
       // restore the rowNum

    reutrn super.executeOnComponent(id, process);

And dont forget to iterate through the facets too. Else you might not
find the component embedded in e.g. an panelLayout (a bug with ajax I
already filed)

No need of instanceof, or do I miss something yet?


View raw message