I am writing a test to see how event handlers should work but it seems I am doing something wrong here because I cannot see the added Widget to the flextable 🙁
Here is my code snippet
Composite A:
B b=new B();
Button addItemButton = new Button("+");
addItemButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Window.alert("Hello world!");
b.addItem(itemTable);
}
});
Composite B:
public void addItem(FlexTable itemTable)
{
itemTable.add(new C());
}
Composite C:
...
Button removeRow=new Button();
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
itemTable.removeRow(?);
}
});
I mean nothing adds to the itemTable when I run it as GWT app in my default Internet Browser. How to refresh ItemTable or something to see its added or removed rows?
Any useful comments are appreciated
You need to look more closely at the GWT Stocks example. This is the code section which actually adds the row:
The call to
stocksFlexTable.setText()is what creates the row in the table and sets the text. So your code forBandCshould look more like this:If you just want to stack a bunch of widgets on top of each other (so if you don’t create more than one column in the table), you should just use the
VerticalPanel. It’sadd()method will do what you were expecting.