0

ActionButtonJavaZul

asked 2015-06-15 16:00:59 +0800

tess gravatar image tess
5 2

(portion of code is below) My add button is from my zul file; I want to set an action for newButton that is created after add button is clicked.How would I do that in java?

Also, how would I use that newButton I created in java and pass it as parameter to my zul file, so I can set an action for newButton in zul?

@Listen("onClick=#add")

    public void add() {

    Tab newTab = new Tab();
    newTab.setLabel(categories.getValue());

    Tabpanel newPanel = new Tabpanel();
    Button newButton = new Button();
    newButton.setLabel("record");

    newPanel.appendChild(newButton);
    tbpanels.appendChild(newPanel);
    tab.appendChild(newTab);



}

Thanks in advance

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2015-06-15 17:28:32 +0800

Darksu gravatar image Darksu
1991 1 4

Hello tess,

For the first question you have to add a event listener to the newly created button as shown at the following fiddle:

http://zkfiddle.org/sample/18np6gm/1-Trigger-button-click-by-click-div-in-JAVA-code#source-2

But make sure that you will not have any unique id space exceptions. For more info please refer to the following:

http://books.zkoss.org/wiki/ZKDeveloper'sReference/UIComposing/IDSpace

Also please refer to the following document that will help understand better component based UI.

Best Regards,

Darksu

link publish delete flag offensive edit
Your reply
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-06-15 16:00:59 +0800

Seen: 10 times

Last updated: Jun 15 '15

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