-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello people (again :D )
I have a ModalDialogController that i do :
Course selected = coursesListbox2.getSelectedItem().getValue();
Map<String, Object> arguments = new HashMap<String, Object>();
arguments.put("selected", selected);
String template = "professor_dialog.zul" ;
Window window = (Window)Executions.createComponents(template, null, arguments);
window.doModal();
* selected is the object that i want to pass *
The professordialog.zul is the modal window that created and there i have some textboxes and one button(like simple form with submit button).So here is my problem.How will i pass this object ("selected" as i said) in the controller of modal window because from there i want to send it with the values of textboxes to a function. In professordialog.zul i tried:
selected course: ${arg.selected} and the value is right but this is not what i want.In the ModalwindowController i tried:
Course test = (Course) Executions.getCurrent().getArg().get(selected); but it is always null if i remember right. In few words i want something like this in the ModalwindowController:
@Listen("onClick = #submitBtnmodal")
public void subModal() {
AuthenticationService authService = new AuthenticationServiceImpl();
UserInfoService userService = new UserInfoImpl();
UserCredential userCredential = authService.getUserCredential();
User user = userService.findUser(userCredential.getAccount());
Course test = (Course) Executions.getCurrent().getArg().get(selected); //the "selected" object that i want to handle that we must "read" from the ModalDialogController
String title = titleTextbox.getValue();
String place = placeTextbox.getValue();
String date = dateTextbox.getValue();
userService.addEvent(title, place, time, user, selected);
}
I hope to made it as clear as possible. Thanks :D
Yes your requirement seems clear and the explanation is simple.
Accessing the parameter passed into the creation of the child page during an event listener, which happens later in a different execution - in ZK an execution is a request, response cycle - results to null. You have to access your parameter during creation of your modal window. e.g. in doAfterCompose
So you got all the pieces right, just called one method at the wrong time.
Here runnable example on ZK fiddle
I'd recommend you to create runnable examples there in order to get responses more quickly and to improve the chance of getting the response you need.
In ModalwindowController i just did:
private Course selected;
public ProfessorDialogController(){
final Execution execution = Executions.getCurrent();
selected = (Course) execution.getArg().get("selected");
}
and i manage to handle it. Thanks :D
Thanks for getting back. good to hear you found a solution.
I would have never guessed that you are not using a ZK-Composer interface but a custom controller class.
So the takeaway: the execution arguments passed into createComponents are only visible during the time of creation of the zul file. So your controller's constructor must be called somewhere during that time.
Asked: 2019-06-01 03:09:57 +0800
Seen: 12 times
Last updated: Jun 03 '19