-
FEATURED COMPONENTS
First time here? Check out the FAQ!
(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
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
Asked: 2015-06-15 16:00:59 +0800
Seen: 10 times
Last updated: Jun 15 '15