-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello!
I have a problem:
I have a list of buttons which are added in a dynamic way, so I don't know the number, but each button is added in a div. In fact I create in a dynamic way a div containing a button.
Then I want that a textbox appears by clicking on a button in this button's div.
I think that I need to get the id of the button clicked but I don't know how to do that.
If someone know how to do or have an other idea... I am completely blocked.
Thank you in advance
Hello pfellmann,
the problem is not to give an Id to the button but to get it from a fonction onClick.
I have the same method for all buttons but I want to know which button has been clicked in order to display something in this button's div.
Thank you for your answer by the way :-)
Sorry, I didn't understand your question in the first place.
You can try :
Public Class myController extends GenericForwardComposer (){ private void myButtonCreationMethod (){ Button myButton = new Button("myButtonLabel"); myButton.setId("myButtonId"); myButton.setAttribute("onClick","myOnClickMethod"); //or maybe mypackage.myController.myOnClickMethod ... I didn't test it } public void myOnClickMethod(Event e){ // ........ } }
you just have to find a way to know what button is pressed, maybe somewhere in e.getXXX ... I don't know, but I think it's in the right way !
Let me know if you find out !
good luck!
Hi, why not ??
add an eventListener
... Button btn = new Button("ZK Guestbook"); btn.setID("btnId"); btn.setParent(getMainMenuWindow()); btn.addEventListener("onClick", new GuestBookListener()); ... } public final class GuestBookListener implements EventListener { @Override public void onEvent(Event event) throws Exception { // get the id of the component event.getTarget().getId() // do something } }
regards
Stephan
Asked: 2009-07-03 08:12:21 +0800
Seen: 623 times
Last updated: Jul 08 '09