vaadin7 table.getvalule() WARNING:

I select the code in the value added to the list of rows in the table: (vaadin7)

list.addItem (table.getItem (table.getValue ()). getItemProperty (“zhengzhuang”));

When prompted:


WARNING: You are using ColumnProperty.toString () instead of getValue () to get the value for a ColumnProperty. This will not be supported starting from Vaadin 7.1 (your debugger might call toString () and cause this message to appear).

The above code should be how to modify? ? Thanks very much!

Try this:


list.addItem(table.getItem(table.getValue()).getItemProperty("zhengzhuang")[b]
.getValue()
[/b]);

Stefan

Hi,

list.addItem takes an item Id. Here you use an Item as ItemId.

I assume that you have a table, from which you want to add items to a select. You could do it something like this:


// Create a table
final Table t = new Table();
t.addContainerProperty("first", String.class, null);
t.addContainerProperty("second", String.class, null);
t.setSelectable(true);

// Let's add some test items
for (int iii = 0; iii < 3000; iii++) {
	t.addItem("" + iii).getItemProperty("first").setValue("someVal");
	t.getItem("" + iii).getItemProperty("second").setValue(iii);
}

// Create a select
final NativeSelect cb2 = new NativeSelect();
cb2.addContainerProperty("zhengzhuang", String.class, null);
// set correct ItemCaption Property, otherwise your ItemId will be displayed
cb2.setItemCaptionPropertyId("zhengzhuang");

// Create a button that adds the item to the list
Button but = new Button("Add item to list");
but.addListener(new Button.ClickListener() {
		
	public void buttonClick(ClickEvent event) {
		// This gets the itemId that is selected
		Object itemId = t.getValue();

		// Return if nothing is selected
		if (itemId == null) return;

		// Get the value from the table
		Object val = t.getItem(itemId).getItemProperty("second").getValue();

		// Lets use the same itemId for your Select. Then add it and you have an editable Item. Get the right property and set the value
		cb2.addItem(itemId).getItemProperty("zhengzhuang").setValue(val);

		// This will select and show the value you just added
		cb2.setValue(itemId);

		// You maybe want to remove the item from the table when it has been moved
		t.removeItem(t.getValue());
	}
}); 

// THen add to your layout
layout.addComponent(t);
layout.addComponent(cb2);
layout.addComponent(but);

Solve the problem, thanks!