Link onClick() method update on runtime
Is there any way to update onClick method for the same link? Let say I have link add(new Link(myLink) { public void onClick() { // do something here... } ); And later, when I click other control I want to update myLink onClick logic public void onClick() { // do something else if button clicked } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-onClick-method-update-on-runtime-tp3568895p3568895.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Link onClick() method update on runtime
Sure, it's just Java: add(new Link(myLink) { public void onClick() { if (buttonClicked) { // do something else if button (was) clicked } else { // do something here... } } }); add(new Button(myButton) { public void onSubmit() { buttonClicked = true; } }); Hope this helps Sven On 06/02/2011 07:21 PM, meduolis wrote: Is there any way to update onClick method for the same link? Let say I have link add(new Link(myLink) { public void onClick() { // do something here... } ); And later, when I click other control I want to update myLink onClick logic public void onClick() { // do something else if button clicked } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-onClick-method-update-on-runtime-tp3568895p3568895.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Link onClick() method update on runtime
I will update this onClick recursive, need some more dynamic solution -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-onClick-method-update-on-runtime-tp3568895p3568935.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Link onClick() method update on runtime
Hi, you can consider to attach/remove behaviors to you link. For example : link = new Link(link){ @Override public void onClick() { } }; link.add(new AjaxEventBehavior(onclick) { protected void onEvent(AjaxRequestTarget target) { System.out.println(ajax here!); } }); When link is clicked Behavior is run before onClick. You can add/remove behaviors according to your needs. I will update this onClick recursive, need some more dynamic solution -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-onClick-method-update-on-runtime-tp3568895p3568935.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Link onClick() method update on runtime
Use the strategy pattern (i.e. changing the strategy each time a button is submitted): http://en.wikipedia.org/wiki/Strategy_pattern Sven On 06/02/2011 07:42 PM, meduolis wrote: I will update this onClick recursive, need some more dynamic solution -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Link-onClick-method-update-on-runtime-tp3568895p3568935.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org