0

MVVM Validator: class not found ? [closed]

asked 2013-02-07 18:23:55 +0800

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

updated 2013-02-08 02:50:01 +0800

jimyeh gravatar image jimyeh
2047 1 4
ZK Team

I tried to implement a validator in my test form. I read some examples obviously I did not understand...

My .zul form

<groupbox form="@id('gbD') @load(vm.selected) @save(vm.selected, before='saveOrder')"
         id="formGroup" visible="@load(not empty vm.selected)" hflex="true" mold="3d"
         validationMessages="@id('vmsgs')">
         <grid hflex="true" >
         <columns>

                    <row>
                     Cognome/Nome
                     <hbox>
                       <textbox  value="@bind(gbD.cognome)" maxlength="50" width="250px" />
                        <textbox  value="@bind(gbD.nome) @validator('vm.Validator1')"
                                                     maxlength="50" width="250px" />
                        <label value="@load(vmsgs['ctxnome'])" sclass="red"/>
                         </hbox>
                       </row>

The textbox field nome has a validator....

public class aaa extends SelectorComposer<Window>
 {
    private static final long serialVersionUID = 1L;
    private List<Utenti> lstUtenti;
    private Utenti selected;
    ....
    public Validator getValidator1()
    {
        return new AbstractValidator()
        {
            public void validate(ValidationContext ctx)
            {
                    String nome = ctx.getProperties("nome")[0].getValue().toString();
                if(nome.equalsIgnoreCase("pirla"))
                {
                    addInvalidMessage(ctx,"ctxnome","non insultare!!!");
                }
            }
        };
    }

When occurs onChange on field I have an class error...

Thanks. Luca

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by sjoshi
close date 2013-02-11 04:54:38

Comments

Thanks, I have correct the string but I receive this error: Property 'Validator1' not found on type rvl.stcc.ui.aaa...

Luca

lramellavotta ( 2013-02-10 15:48:34 +0800 )edit

I saw you use selector composer to be a viewmodel, and didn't see how you use it, please ready mvvm doc to know the basic about a viewmodel first,

dennis ( 2013-02-10 16:11:04 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-02-08 04:37:21 +0800

this post is marked as community wiki

This post is a wiki. Anyone with karma >100 is welcome to improve it.

updated 2013-02-08 04:37:21 +0800

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

Change @validator('vm.Validator1')" to @validator(vm.Validator1)"

'vm.Validator1' is an expression and get the static string result

link publish delete flag offensive edit

Question tools

Follow
3 followers

RSS

Stats

Asked: 2013-02-07 18:23:55 +0800

Seen: 43 times

Last updated: Feb 10 '13

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