0

@command and close window

asked 2012-03-26 14:32:05 +0800

deggesim gravatar image deggesim
36 1

updated 2012-03-26 14:33:15 +0800

In my application I have a modal window not "closable".
In this window I have two buttons, one to close and one that performs business logic by @command('save').

<zk>
	<window id="window" width="700px" title="@load(vm.title)" border="normal" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('it.eng.fbm.viewmodel.MyVM')">
...
...
...
		<button label="${c:l('resultedit.button.save')}" onClick="@command('save')" ></button>
		<button label="${c:l('resultedit.button.undo')}" onClick="window.onClose()" ></button>
...
...
...
	</window>
</zk>

The implementation of this command needs the Window reference to close the window:

@Command
	public void save(@SelectorParam("#window") Window window) {
		try {
			// do buiseness logic
			window.onClose();
		} catch (ApplicationException e) {
			log.error(e.getMessage());
			e.printStackTrace();
		}
	}

This breaks decoupling between the view and the model.
Is there a way to avoid it?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-03-28 07:05:33 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

I posted a request here http://tracker.zkoss.org/browse/ZK-986

link publish delete flag offensive edit

answered 2012-03-28 13:49:04 +0800

deggesim gravatar image deggesim
36 1

Thank you.

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: 2012-03-26 14:32:05 +0800

Seen: 776 times

Last updated: Mar 28 '12

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