you are not approaching the problem properly, at least not from compositing perspective. you would not create arrays of components to populate the listview, you would forward the listview's abstract callback to the panel, after all what if the listview is pageable?

abstract ComponentA extends Panel
{
    public ComponentA( String id )
    {
super( id );
add( new ListView( "listOfB", list ) )
{
        public void populateItem( ListItem item )
{
populateMyItem(item, "componentB");
}
}
        ...
    }

protected abstract populateMyItem(ListItem item, String componentId);
}


ComponentA a=new ComponentA("a") {
    populateMyItem(ListItem item, String componentId) {
        add(new ComponentB(componentId));
    }
};

add(a);

in 1.3 we will remove the add() call and require the parent in the constructor next to id instead - might seem even more inconvinient from your pov. this will give us a lot more features such as:
components will have access to their attributes/markup in the constructor
line precise errors for hierarchy inconsistencies at component creation time instead of render time
and a lot more, there was a long discussion on this or the devel list a while back if you want to dig around.

-Igor



Reply via email to