/** * Adds the given components into this notification. * <p> * The elements in the DOM will not be children of the * {@code <vaadin-notification>} element, but will be inserted into an * overlay that is attached into the {@code <body>}. * <p> * NOTE: When mixing this method with {@link #Notification(String)}, * {@link #Notification(String, int)} and * {@link #Notification(String, int, Position)} method will remove the text * content. * * @param components * the components to add */ @Override public void add(Component... components) { Objects.requireNonNull(components, "Components should not be null"); for (Component component : components) { Objects.requireNonNull(component, "Component to add cannot be null"); container.appendChild(component.getElement()); } attachComponentTemplate(); }
/** * Adds the given component into this notification at the given index. * <p> * The element in the DOM will not be child of the * {@code <vaadin-notification>} element, but will be inserted into an * overlay that is attached into the {@code <body>}. * <p> * NOTE: When mixing this method with {@link #Notification(String)}, * {@link #Notification(String, int)} and * {@link #Notification(String, int, Position)} method will remove the text * content. * * @param index * the index, where the component will be added. * @param component * the component to add */ @Override public void addComponentAtIndex(int index, Component component) { Objects.requireNonNull(component, "Component should not be null"); if (index < 0) { throw new IllegalArgumentException( "Cannot add a component with a negative index"); } // The case when the index is bigger than the children count is handled // inside the method below container.insertChild(index, component.getElement()); attachComponentTemplate(); }