vaadin / vaadin-core

Home Page:https://vaadin.com/docs/latest/ds/overview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Semantics of using the same components as helpers are unclear

edler-san opened this issue · comments

Tested with V14.4.0.alpha1 and the bookstore example:
In ProductForm.java I added

        Image img = new Image("https://vaadin.com/images/vaadin-logo.svg","Vaadin logo");
        img.setWidth("180px");
        img.setHeight("100px");
        productName.setHelperComponent(img);
        ...
        price.setHelperComponent(img);

I get
image

I would have expected that either I get the image below both components (preferred!) or at least have a note in the javadoc that only the last called component gets the child.

It's forbidden to add a component twice. So if you add an Image in the first component then in the second component, it's removed in the first component then re-attached.

Can you add that to the javadoc?

That you can't add the same instance of a Component two times in a Vaadin application? It's not related to the the helper. I don't know if it's already documented?

(Note: I'm a tester, I've got the same bug as your first one and read this one :) )

(Note: I'm a tester, I've got the same bug as your first one and read this one :) )

My bad. :)

Also, it does work in Swing so It is not immediately obvious why it shouldn't here.

    JPanel panel = new JPanel();
    panel.add(new JLabel("Hello"));
    java.awt.Image img = ImageIO.read( new URL("https://yourhost.here/ball.png"));
    panel.add("Foo", new JLabel(new ImageIcon(img)));
    panel.add("Bar", new JLabel(new ImageIcon(img)));
    JButton ok = new JButton("OK");

renders image

As mentioned by @jcgueriaud1 , the same component can't be added twice. This isn't specific to the component but Vaadin in general. Closing as wontfix