2

Vaadin (6.7.4) を使用していますが、このテーブル(モーダル ウィンドウ上にあります)はビューを更新しません。

最初は生成された列で作成されましたが、テーブルの更新に問題があると読んだので、通常のテーブルに戻しましたが、まだ更新されていません。

Updatedata は、パネル上のボタン クリック イベントによって呼び出されます。

final Table table = new Table();
final IndexedContainer ic=new IndexedContainer();

public createTable(){
    table.setImmediate(true);   
    table.setEnabled(true); 
    ic.addContainerProperty("Name", String.class,  null);
    ic.addContainerProperty("Edit", Button.class, null);
    ic.addContainerProperty("Delete", Button.class,  null);
    table.setContainerDataSource(ic);
}

public void addItems(Table table) {
    for (String s : createdNames) {
        ic.addItem(s);
        ic.getItem(s).getItemProperty("Name").setValue(s);
        ic.getItem(s).getItemProperty("Edit").setValue("Edit");
        ic.getItem(s).getItemProperty("Delete").setValue("Delete");
    }

}

public void updateData() {      
    IndexedContainer c=(IndexedContainer) table.getContainerDataSource();
    c.removeAllItems();
    c.addItem("myname");
    c.getContainerProperty("myname", "Name").setValue("Mr.X");
    table.setContainerDataSource(c);
    table.refreshRowCache();
    table.requestRepaint();
    System.out.println("see the output but no update on table");
}

編集:問題はこのコードに関するものではないことが判明しましたが、このクラスは2回インスタンス化されたため、異なるインスタンスがありました。私が更新しているものと私が見ているもの。

4

2 に答える 2

3

動作する完全な Vaadin アプリケーションを次に示します。

public class TableTest extends Application {
final Table table = new Table();
final IndexedContainer ic = new IndexedContainer();

@Override
public void init() {
    setMainWindow(new Window("Window"));
    createTable();
    getMainWindow().addComponent(table);
    getMainWindow().addComponent(
            new Button("Click me", new Button.ClickListener() {
                public void buttonClick(ClickEvent event) {
                    updateData();
                }
            }));
}

public void createTable() {
    table.setImmediate(true);
    table.setEnabled(true);
    ic.addContainerProperty("Name", String.class, null);
    ic.addContainerProperty("Edit", Button.class, null);
    ic.addContainerProperty("Delete", Button.class, null);
    table.setContainerDataSource(ic);
}

public void updateData() {
    ic.removeAllItems();
    ic.addItem("myname");
    ic.getContainerProperty("myname", "Name").setValue("Mr.X");
    System.out.println("see the output but no update on table");
}
}

問題はコードの別の場所にあるようです。ところで、将来的には、まったく新しいアプリケーションをゼロから作成して、問題を特定し、それが自分の考えている場所にあることを検証する必要があります。

于 2012-06-06T09:45:53.410 に答える