if( hw.getWidget() instanceof BoundWidget ){
old = (BoundWidget<?>) hw.getWidget();
}
hw.setWidget( (Widget) widget );
} else if( panel instanceof HasWidgets ){
HasWidgets hw = (HasWidgets) panel;
Iterator<Widget> it = hw.iterator();
while(it.hasNext()) {
Object next = it.next();
if(next instanceof BoundWidget) {
old = (BoundWidget<?>) next;
break;
}
}
hw.clear();
hw.add((Widget) widget );
}
FlowEvent event = context.createEvent(contextRoot, name, widget, old );
if(fireEvents){
context.fireEvent(event);
}