I was wondering, as a New user, if this is a safe thing to do.
My doubt is based on the First Paragraph in the Vaadin book (6.2) pg 73
“Using captions or any other visible text is generally discouraged …”
Button b = new Button("mybtn",this);
b.setData("mybtn");
Button b = new Button("mysecondbtn",this);
b.setData("mysecondbtn");
public void buttonClick(ClickEvent event){
String id =(String)( event.getButton).getData();
//process buttons based on this.
}
I prefer the use of anonymous inner classes for listeners because it basically shrinks the amount of code you need to write. So you should consider something like:
Button b = new Button(“mybtn”, new Button.ClickListener() {
@Override
public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
// write your click handler code
}
});
I suppose it’s ok. One issue is with comparing the string keys; it is always better if things are checked compile-time. Perhaps storing the button references in member variables would be better, although it adds a bit clutter to the class.