table.addItem is not adding the value to my table
When I add the table.addContainerProperty manually (all of them) it works, adding all items i ask for.
When I use a for to create the table.addContainerProperty I cannot add values using my button, or with the for that should add all my values.
Why? I cannot find it anywhere...
package br.com.Metrics;
import com.vaadin.Application; import
com.vaadin.ui.Button; import
com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Table; import
com.vaadin.ui.Window;
import br.com.cflex.table.*;
/** * The Application's "main" class
*/ @SuppressWarnings("serial") public class MyVaadinApplication extends Application {
private Window window;
private Table table;
@O开发者_Python百科verride
public void init()
{
window = new Window("My Vaadin Application");
table = new Table("Teste de tabela");
table.addItem();
table.addContainerProperty("Nome", String.class, null);
for(int i=0; i<10;i++){
table.addContainerProperty(i,Integer.class, null);
table.addItem(new Object[] {"2",new Integer(159),new Integer(1473)}, null);
}
for(int i=0; i<10; i++){
table.addItem(new Object[] {"3",new Integer(159),new Integer(1473)}, null);
}
table.addItem(new Object[] {"4",new Integer(159),new Integer(1473)}, null);
Button button = new Button("Press Me !");
button.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
table.addItem(new Object[] {"Nicolaus",new Integer(159),new Integer(1473)}, null);
}
});
window.addComponent(table);
window.addComponent(button);
setMainWindow(window);
}
}
I found out why...
when inserting data in a table using .addItem the array that you must provide to this method MUST have the exact same number of itens as the table columns.
otherwise it will not add them or tell you that.
精彩评论