How could I catch Component's events ?

Hi all,

I have a class called FormSg which extends VerticalLayout.
In this class I have some buttons.
I’d like to control the events of these buttons from outside the class.
I mean, I display the class FormSg in a pop-up window so when an user click a button of the class I’d like to manage the event from the caller.
So, is there any method like FormSg.addListener(new ClickListener(Event event) {…} to declare in the caller class ?
In this way I could control all the button events from outside and not put code inside the FormSg.
Cheers.

                  Stefano

Hi,

there isn’t a method like the one you describe. The way I’ve usually handled these situations is that I’ve created a very simple listener interface, let’s say FormSgListener, which would then contain one method declaration for each button action. Your controller would then implement this interface and thus get all the button click events. The downside is that this approach requires some boilerplate code in the FormSg class, basically adding a click listener for all the buttons and then forwarding those calls to the custom listener. Luckily this logic is very simple and can be mostly autogenerated by the ide.

-tepi