-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello.
I have a main.zul where i make a listbox with id "coursesEventsListboxProf".There i have a button that calls ModalDialogController (like the zk examples).In ModalDialogController i just do
Window window = (Window)Executions.createComponents( "professor_dialog.zul", null, null);
and
window.doModal();
In professor_dialog.zul i just have a grid with 3 textboxes.There when the user fill out the textboxes, i have a button with id="subBtnmodal" and a controller called UserDataController from where i handle the values of textboxes. The thing is that i want to handle the listbox with the id "coursesEventsListboxProf" but i get NullPointerException (obviously) and i dont know how to "pass" it from main.zul. Thanks.
Looks like there are at least 2 controllers with parent-child relationship. You can get a component reference of a parent page in a child page, but this approach makes 2 controllers more coupling.
It's better to post an event among them, e.g.
parent page can add an event listener for a custom event:
window.addEventListener("onInnerButtonClicked", e -> {update listbox})
when a user clicked subBtnmodal
, you just post an event like:
Events.postEvent(window," onInnerButtonClicked")
Please refer to Inter-Page_Communication
you can pass id with the last arguments like:
Window window = (Window)Executions.createComponents( "professor_dialog.zul", null, Collections.singletonMap("listbox", "coursesEventsListboxProf"));
In the controller of professor_dialog.zul
, you can get passed id with Execution.getArg()
refer to javadoc
an alternative to Pass ID is to pass the component instance directly:
Window window = (Window)Executions.createComponents( "professor_dialog.zul", null, Collections.singletonMap("listbox", coursesEventsListboxProf));
In the controller of professor_dialog.zul
Listbox lb = (Listbox)Execution.getArg("listbox");
Still if sufficient I'd prefer the event based approach.
Asked: 2019-05-29 18:42:46 +0800
Seen: 14 times
Last updated: May 30 '19
ZK Listbox Selectitems issue with Set
How to stop a bug from a listbox?
Cannot Change Listbox Header color & Background
Keyboard navigation in listbox
Can not display data in listbox
listbox with nonSelectabletags inplace new listitem
Input invoice using inline listbox
Change color to hover listitem listbox zk7 + Atlantic Theme
Listbox with autopaging causes constant row flickering
zk listbox getItems() returns null for item.getValue() if not scrolled fully