0

I have an application where the user can modify an entity, say customer, by modifying a bunch of text-boxes, list-boxes, date-pickers and check-boxes. I also have 2 buttons, save and cancel. I would like to enable the save button if an actual change was made (i.e. one of the input widgets has been modified). Obviously, this can be done in a "brute-force" way by manually adding a change listener to every widget. Or a slight improvement could be to define lists of widgets and add listeners in a for loop. I am curious whether anyone has a more elegant solution?

Thanks, Matyas

4

1 回答 1

2

如果你使用 UiBinder,你可以使用类似的东西:

@UiField TextBox textBoxA;
@UiField TextBox textBoxB;
@UiField TextBox textBoxC;
@UiField DatePicker datPickerA;
@UiField RadioButton radioButton;

...

@UiHandler(value={"textBoxA", "textBoxB", "textBoxC", "datePickerA"})
void somethingChanged(ChangeEvent e) {
  // Enable your save button.
}

@UiHandler("radioButton")
void somethingClicked(ClickEvent e) {
  // Enable your save button.
}
于 2012-05-12T07:55:43.467 回答