-
FEATURED COMPONENTS
First time here? Check out the FAQ!
good night all,
before I using form="@id('fx')",, save, reset & search buttons working fine but without any validation, after I modify became the following code, save & reset still working fine but search button not works.
Would you like to explain me about @load @save and before | after work with viewmodel.
[edited] based on my code below, save button & reset button works fine, but search button doesnt work, when I treid to trace the object 'current' when search button was clicked however the object 'current' is null, why ? how to get object from textbox that fill with some character when search button was clicked ?
thanks [/edited]
<groupbox form="@id('fx') @load(vm.current) @save(vm.current, before='save') @validator(vm.formValidator)">
<row>
<cell>Username</cell>
<cell><textbox value="@bind(fx.username)" type="text" focus="true" /></cell>
<cell><label sclass="red" value="@bind(vmsgs['fkey1'])"/></cell>
</row>
<button label="Save" onClick="@command('save')" image="/image/iconcrud/btn_save.gif" />
<button label="Reset" onClick="@command('reset')" image="/image/iconcrud/btn_reset.gif" />
<button label="Search" onClick="@command('search')" image="/image/iconcrud/btn_search.gif" />
Thanks
attr = @load(expression,after='cmd') : load
the expression to attr after
the command
'cmd'
attr = @save(expression,before='cmd') : save
the attr to expression to attr before
the command
'cmd'
and after & before are all evaluated after the validation and command execution.
we usually use before='cmd' on @save and use @load after='cmd' or both without condition (how ever you could still use @save after='cmd' or @load before='cmd' just by case)
please read document
thank dennis,
base on my code above when I entry on username textbox, then I click Search button however object vm.current is null, how to set object vm.current is not null when I click Search button ?
this my code for search command
@NotifyChange("listModel")
@Command("search")
public void search(){
System.out.println("current search : "+current.getUsername());
listModel = new ListModelList<Mstuser>();
listModel.addAll(getMasterFacade().getMstuserDao().findByCriteria(current));
}
but when I click save button its works, this my code for save command :
@NotifyChange({"listModel","current"})
@Command("save")
public void save() {
String passwd = PasswdUtil.getMD5DigestFromString(current.getPassword());
current.setPassword(passwd);
getMasterFacade().getMstuserDao().saveOrUpdate(current, "userLogin");
current = new Mstuser();
listModel = new ListModelList<Mstuser>();
listModel.addAll(getMasterFacade().getMstuserDao().findAll());
}
thank.
Asked: 2013-02-18 16:16:28 +0800
Seen: 237 times
Last updated: Feb 21 '13
Problem binding values to a composite component
How to access static member field of a class in zul without zscript
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
MVVM tab box - delay @load until tab pane displayed?
how to fire an event when a variable value loaded through VM
is there any event trigger from zk component on binding ?
ZK team plans to dispose of Composer EventQueues no longer in scope? [closed]
[Ugent please] connect Web service .net view in grid group ZK