mvvm, load or save with after or before for seach command

asked 2013-02-18 16:16:28 +0800

progamerdotcom gravatar image progamerdotcom
117 5

updated 2013-02-21 08:59:01 +0800

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)">

<cell><textbox value="@bind(fx.username)" type="text" focus="true" /></cell>
    <cell><label sclass="red" value="@bind(vmsgs['fkey1'])"/></cell>

<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" />


delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-02-19 06:44:32 +0800

dennis gravatar image dennis
3669 1 6

updated 2013-02-19 06:46:31 +0800

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

link publish delete flag offensive edit

answered 2013-02-21 04:12:28 +0800

progamerdotcom gravatar image progamerdotcom
117 5

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

public void search(){
    System.out.println("current search : "+current.getUsername()); 
    listModel = new ListModelList<Mstuser>();

but when I click save button its works, this my code for save command :

public void save() {

    String passwd = PasswdUtil.getMD5DigestFromString(current.getPassword());
    getMasterFacade().getMstuserDao().saveOrUpdate(current, "userLogin");
    current = new Mstuser();

    listModel = new ListModelList<Mstuser>();



link publish delete flag offensive edit


Hi, could you edit the original question , append the information you provided lastly, to keep the Q-A style.

dennis ( 2013-02-21 07:33:55 +0800 )edit

thanks, I already edit my question.

progamerdotcom ( 2013-02-21 09:00:28 +0800 )edit
Your answer
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

1 follower



Asked: 2013-02-18 16:16:28 +0800

Seen: 214 times

Last updated: Feb 21 '13

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