Ticket #1137 (closed defect: fixed)

Opened 14 months ago

Last modified 11 months ago

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

Changed 14 months ago by Jani Laakso

  • version set to 5.0.0-pre

Changed 14 months ago by Jani Laakso

  • milestone deleted

Changed 12 months ago by Joonas Lehtinen

  • milestone set to User Interface Library 5.1.0 RC

Changed 11 months ago by Jani Laakso

  • status changed from new to assigned

Changed 11 months ago by Marc Englund

Should fix #71 as well.

Changed 11 months ago by Marc Englund

Fixed in [3698].

AbstractComponent?.setParent(parent) cannot be called if component already has parent, unless the new parent is null (unsetting parent).

AbstractComponentContainer?.addComponent(component) removes the component from it's previous ComponentContainer? if needed (moves component), or throws if the component can't be removed.

All components that contain other components should implement ComponentContainer? for this to be perfect (e.g CustomComponent?, Table)"

Changed 11 months ago by Marc Englund

  • owner changed from Jani Laakso to Marc Englund
  • status changed from assigned to new

Changed 11 months ago by Marc Englund

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.