table.addItem 没有将值添加到我的表中
当我手动添加 table.addContainerProperty (所有这些)时,它会起作用,添加我要求的所有项目。
当我使用 for 创建 table.addContainerProperty 时,我无法使用按钮添加值,或者使用 for 应该添加我的所有值。
为什么?我在任何地方都找不到它...
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;
@Override
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);
}
}
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;
@Override
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);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了为什么......
当使用 .addItem 在表中插入数据时,您必须提供给此方法的数组必须具有与表列完全相同的 itens 数量。
否则它不会添加它们或告诉你。
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.