0

Questions with Modal Window

asked 2009-10-03 15:21:56 +0800

cryandaguo gravatar image cryandaguo
72 2

updated 2009-10-03 15:26:25 +0800

1) A bug that happened in zk 5.0.0RC and FL
in zk demo 5.0.0RC and FL in the Modal Dialog section,
click the button to make a modal window, the modal window will shield the background, you can not touch the background
then maximize the modal window and minimize it again, you will find the shield shadow is no more exist, you can control the background within the modal window existed.
this only happened in zk 5.0.0RC and FL, it is not a bug in the zkdemo 3.6.3 in the zkoss site.
where I can get the zk3.6.3?
2) how should I communicate between modal window and the background.
there is a listbox with lots datas in the base window, I need a modal window to allow user update or add one row in the listbox.
after user fill the row detail form in the modal window, he click the "confirm" button in the modal window, this "confirm" event should collect the form data he filled in and close the modal window at first,
then communicate with the listbox in the background to update or add a row in that listbox.
this background and modal window is in 2 different zul file.
I don't know how to get the backgrund listbox in the modal window, I define a update method in the background zul file to update the listbox, how can I access this method in the modal window?

any help would be very appreciated!

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2009-10-03 20:02:14 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2009-10-03 20:19:55 +0800

1.) http://sourceforge.net/projects/zk1/files/ZK%20Freshly/

2. if you create your window with Executions.createComponent(""/pages/myModalWindow.zul, null, map )
you can overhanded to the new Window your underlaying winController as a param in the 'map' .

	
                         ...

                         /*
			 * We can call our Dialog zul-file with parameters. So we can call
			 * them with a object of the selected item. For handed over these
			 * parameter only a Map is accepted. So we put the object in a
			 * HashMap.
			 */
			HashMap map = new HashMap();
			map.put("branche", branche);
			/*
			 * we can additionally handed over the listBox, so we have in the
			 * dialog access to the listbox Listmodel. This is fine for
			 * syncronizing the data in the customerListbox from the dialog when
			 * we do a delete, edit or insert a customer.
			 */
			map.put("lbBranch", listBoxBranch);
	-->   -->   --> map.put("branchCtrl", this);

                        // call the zul-file with the parameters packed in a map
			Window win = null;
			try {

				win = (Window) Executions.createComponents("/WEB-INF/pages/branch/branchDialog.zul", null, map);
			} catch (Exception e) {
				logger.error("onOpenWindow:: error opening window / " + e.getMessage());

				// Show a error box
				String msg = e.getMessage();
				String title = Labels.getLabel("message_Error");

				MultiLineMessageBox.doSetTemplate();
				MultiLineMessageBox.show(msg, title, MultiLineMessageBox.OK, "ERROR", true);

				if (win != null) {
					win.detach();
				}
			}

		}


on the ModalWindow controller side you can check if there are params overhanded.
--> args.containsKey("branchCtrl") if found than cast and get it.

	/**
	 * Before binding the data and calling the dialog window we check, if the
	 * zul-file is called with a parameter for a selected user object in a Map.
	 * 
	 * @param event
	 * @throws Exception
	 */
	public void onCreate$window_BranchesDialog(Event event) throws Exception {

		if (logger.isDebugEnabled()) {
			logger.debug("--> " + event.toString());
		}

		doOnCreateCommon(window_BranchesDialog, event); // autowire the vars

		/* set components visible dependent of the users rights */
		doCheckRights();

		// create the Button Controller. Disable not used buttons during working
		btnCtrl = new ButtonStatusCtrl(btnCtroller_ClassPrefix, btnNew, btnEdit, btnDelete, btnSave, btnClose);

		if (args.containsKey("branche")) {
			branche = (Branche) args.get("branche");
			setBranche(branche);
		} else {
			setBranche(null);
		}

		// we get the listBox Object for the branch list. So we have access
		// to it and can synchronize the shown data when we do insert, edit or
		// delete branches here.
		if (args.containsKey("lbBranch")) {
			lbBranch = (Listbox) args.get("lbBranch");
		} else {
			lbBranch = null;
		}

		if (args.containsKey("branchCtrl")) {
			branchCtrl = (BranchListCtrl) args.get("branchCtrl");
		} else {
			branchCtrl = null;
		}

		// set Field Properties
		doSetFieldProperties();

		doShowDialog(getBranche());

	}



	/**
	 * opens the dialog window in modal mode.
	 */
	public void doShowDialog(Branche branche) throws InterruptedException {

                ...

       	        try {
                 ...

			window_BranchesDialog.doModal(); // open the dialog in modal mode
		} catch (Exception e) {
			Messagebox.show(e.toString());
		}


more sources you can find here .

the whole code of the sample application you can find here
regards
Stephan

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

RSS

Stats

Asked: 2009-10-03 15:21:56 +0800

Seen: 1,501 times

Last updated: Oct 03 '09

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