0

Passing object to modal controller in order to handle it [closed]

asked 2019-06-01 03:09:57 +0800

GioZiak gravatar image GioZiak
1

updated 2019-06-03 09:44:48 +0800

cor3000 gravatar image cor3000
4546 2 7
ZK Team

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

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by cor3000
close date 2019-06-04 09:44:56

3 Replies

Sort by ยป oldest newest

answered 2019-06-03 10:09:18 +0800

cor3000 gravatar image cor3000
4546 2 7
ZK Team

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.

link publish delete flag offensive edit

answered 2019-06-03 16:36:51 +0800

GioZiak gravatar image GioZiak
1

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

link publish delete flag offensive edit

answered 2019-06-03 17:23:07 +0800

cor3000 gravatar image cor3000
4546 2 7
ZK Team

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.

link publish delete flag offensive edit

Question tools

Follow
1 follower

RSS

Stats

Asked: 2019-06-01 03:09:57 +0800

Seen: 8 times

Last updated: Jun 03

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