Watt
(Watt Lee)
June 21, 2013, 7:40am
1
Following code works fine in vaadin 6.8.x:
[code]
CheckBox checkbox = new CheckBox(“Checked”, true);
checkbox.setImmediate(true);
checkbox.addListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
CheckBox checkbox = (CheckBox) event.getButton();
…
}
});
[/code]But CheckBox.addListener(ClickListener listener) is not implemented in vaadin 7.0.x, If I want to switch to vaadin 7, what should the code be modified?
15544
(Syam Pillai)
June 21, 2013, 8:03am
2
Use addValueChangeListener instead.
Watt
(Watt Lee)
June 21, 2013, 9:08am
3
How can I know which checkbox is value changed? Checkboxes are generated in table rows.
Lipeng
(Lipeng Han)
June 21, 2013, 9:18am
4
table.addGeneratedColumn("name", new Table.ColumnGenerator() {
@Override
public Object generateCell(Table source, Object itemId, Object columnId) {
final Object str = source.getItem(itemId).getItemProperty("name").getValue();
CheckBox box = new CheckBox();
box.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
Object value = event.getProperty().getValue();
boolean isCheck = (null == value) ? false : (Boolean) value;
Notification.show("name:" + str + "isChecked:" + isCheck);
}
});
return box;
}
});
Watt
(Watt Lee)
June 21, 2013, 12:11pm
5
Thank you, Syam and Bill.
I change checkbox to be final, then it can be accessed in ValueChangeListener:
final CheckBox checkbox = new CheckBox();
Anton126
(Anton Tovstonozhenko)
December 9, 2015, 8:12pm
6
Hi!
Is it possible to add onClickListener event?
ValueChangeEvent event is fired when the value has been already changed.
I want to show pop-up with confirmation.