您可以使用集合来存储新添加TextBox
的内容,以后可以从中获取所有值。像这样的东西:
public class Test extends Composite {
private static TestUiBinder uiBinder = GWT.create(TestUiBinder.class);
interface TestUiBinder extends UiBinder<Widget, Test> {}
@UiField
FlowPanel textboxplaceholder;
@UiField
Button addDynamicTextboxbutton;
private LinkedList<TextBox> boxes;
public Test() {
initWidget(uiBinder.createAndBindUi(this));
boxes = new LinkedList<TextBox>();
}
@UiHandler("addDynamicTextboxbutton")
void addMoreTextbox(ClickEvent event) {
TextBox box = new TextBox();
textboxplaceholder.add(box);
boxes.add(box);
}
}
遍历存储在其中的框boxes
以获取所有值。