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