Ticket #1137 (closed defect: fixed)
Adding the same component instance multiple times should throw
| Reported by: | Marc Englund | Owned by: | Marc Englund |
|---|---|---|---|
| Priority: | minor | Milestone: | User Interface Library 5.1.0 RC |
| Component: | Server-side framework | Version: | 5.0.0-pre |
| Keywords: | Cc: | ||
| Known Issue description: | |||
| Hours estimate: | Deadline (dd.mm.yyyy): | ||
| Known Issue version (since): | Known Issue title: | ||
| Hours done: | Depends to: | ||
| Affects documentation: | no | ||
| Known Issue workaround: | |||
| Affects release notes: | yes | Contract: | |
Description
Adding the same component instance to the same application multiple times (so that the same component instance exists in the application component hierarchy multiple times) should trow:
layoutA.addComponent(component); layoutB.addComponent(component); // should throw
Currently it's very easy to make add the same component twice, which will not fail, but cause strange things to happen.
Something like:
AbstractComponentContainer.addComponent(Component c) {
ComponentContainer parent = c.getParent();
if (parent!=null&&parent.contains(c)) {
// NOTE ComponentContainer does not have a contains() -method
throw new SomeSuitableException("The component is already added to...");
}
c.setParent(this);
fireComponentAttachEvent(c);
}
Change History
Note: See
TracTickets for help on using
tickets.
