-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
lets assume I have a grid which is empty on start time, then during runtime it gets filled with rows (from Java code). Now, I would need a button in a cell in every row which has assigned an onClick event. I know how I can create the button on the fly, but how can I assign an event to it during runtime?
Thanks for any hints.
Hello Tegomena
You can register a event listener in your button, when you are creating your button you can add this listener to your button
private EventListener eventListener = new EventListener() {
public void onEvent(Event event) throws Exception {
if (Events.ON_CLICK.equals(event.getName())) {
doProcess();
}
}
};
you can add this listener using
addEventListener(Events.ON_CLICK, eventListener);
this can be done after button has been composed using the afterCompose method, the doProcess() method is where you can do whatever processing you want to do on the posting of event.
Hello Tegomena,
Just to add be careful not to add multiple event listeners of the same type to a component.
Best Regards,
Darksu
Thank you very much, I think I understand it ;-)
Asked: 2015-03-30 19:38:02 +0800
Seen: 37 times
Last updated: Apr 09 '15