0

[Solved] Creating components and events on the fly

asked 2015-03-30 19:38:02 +0800

Tegomena gravatar image Tegomena
33 4

updated 2015-04-09 09:53:21 +0800

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.

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2015-03-31 02:18:40 +0800

echarish gravatar image echarish flag of Japan
1809 7
http://jp.linkedin.com/in...

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.

link publish delete flag offensive edit
0

answered 2015-03-31 03:55:37 +0800

Darksu gravatar image Darksu
1991 1 4

updated 2015-03-31 03:56:29 +0800

Hello Tegomena,

Just to add be careful not to add multiple event listeners of the same type to a component.

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2015-03-31 10:02:40 +0800

Tegomena gravatar image Tegomena
33 4

Thank you very much, I think I understand it ;-)

link publish delete flag offensive edit

Comments

1

You are welcome :)

echarish ( 2015-04-01 01:19:13 +0800 )edit

If it works for you, can you accept the answer, so that status could be changed to answered instead or open.

echarish ( 2015-04-01 02:49:08 +0800 )edit

Sorry for the delay, easter holidays :-) ... thanks again for your help!

Tegomena ( 2015-04-09 09:51:02 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-03-30 19:38:02 +0800

Seen: 37 times

Last updated: Apr 09 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More