Label on Absolute Layout gets duplicated when setting caption

Hello,

I came across an issue in Vaadin 7. When I use the AbsoluteLayout and change the caption of an existing label in it, the label will appear duplicated, just above the original (see attached screenshot).

I have attached a sample code. Is there anything I am missing? I tried removing the label and adding it again, which causes an error (component not belonging to layout); also tried markasdirty, but does nothing.

Thanks,
David


public class MyCanvas extends AbsoluteLayout implements ClickListener{

	private Label lbl1;
	private Label lbl2;
	private Button btn;
	
	public MyCanvas(){
		this.setWidth("300px");
		this.setHeight("300px");
		
		lbl1 = new Label("label 1");
		ComponentPosition position = new ComponentPosition();
		position.setLeftValue(30F);
		position.setTopValue(30F);
		this.addComponent(lbl1);
		this.setPosition(lbl1, position);
		
		
		lbl2 = new Label("label 2");
		ComponentPosition position2 = new ComponentPosition();
		position2.setLeftValue(60F);
		position2.setTopValue(60F);
		this.addComponent(lbl2);
		this.setPosition(lbl2, position2);
		
		
		btn = new Button("Modify buttons' caption");
		btn.addClickListener(this);
		this.addComponent(btn);
		
		
	}

	@Override
	public void buttonClick(ClickEvent event) {
		lbl1.setCaption("caption 1 changed");
		lbl2.setCaption("Caption 2 changed");
	}

12742.png

Sorry I forgot to add some useful information:

Vaadin version: 7.0.0.rc1

Browser:

  • Chrome 24.0.1312.52 m
  • Firefox 18.0.1
  • Internet Explorer 9

Server: Apache Tomcat 7.0.30

Regards,
David Jerónimo

Hi,

the issue is that you’re mixing value and caption. On lines 12 and 20 in your code you set the value of the label, but on lines 37-38 you set the caption. Change the setCaption calls to setValue calls and the issue should be resolved.

Hi Teppo,

That fixed the issue.

Thanks a lot