-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I like to use Zk6/MVVM to create manay read-only screens. They don't require to keep as state at server as soon as UI gets populated.
I like to have 2 options
(1) destroy vm objects as soon as UI get populated.
(2) destroy subset of "state" varaibles when UI get populated.
Any solutions? Thanks for help
Chi Wu
Hi,
You may try the stubonly attribute of components, and call removeBindings after rendered,
for example,
zul file:
<zk> <window id="mainWin" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('test.TestVM')" onCreate="@command('clear')" stubonly="true"> <label value="@load(vm.msg)" stubonly="true" /> <label value="@load(vm.msgTwo)" stubonly="true" /> </window> </zk>
VM
package test; import org.zkoss.bind.Binder; import org.zkoss.bind.annotation.*; import org.zkoss.zk.ui.*; public class TestVM { Boolean msgRendered = false; Boolean msgTwoRendered = false; public String getMsg () { msgRendered = true; return "msg"; } public String getMsgTwo () { msgTwoRendered = true; return "msgTwo"; } @Command public void clear (@ContextParam(ContextType.BINDER) Binder binder) { if (msgRendered && msgTwoRendered) { // clear data msgRendered = null; msgTwoRendered = null; Desktop d = Executions.getCurrent().getDesktop(); for (Component c : d.getComponents()) { if ("mainWin".equals(c.getId())) { // remove binding binder.removeBindings(c); } } } } }
For more information, please refer to Specify Stubonly for Client-only Components
Regards,
Ben
Asked: 2012-04-20 17:48:56 +0800
Seen: 182 times
Last updated: Apr 26 '12