-
FEATURED COMPONENTS
First time here? Check out the FAQ!
asked 2013-02-07 18:23:55 +0800
This post is a wiki. Anyone with karma >100 is welcome to improve it.
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
answered 2013-02-08 04:37:21 +0800
This post is a wiki. Anyone with karma >100 is welcome to improve it.
Change @validator('vm.Validator1')" to @validator(vm.Validator1)"
'vm.Validator1' is an expression and get the static string result
Asked: 2013-02-07 18:23:55 +0800
Seen: 43 times
Last updated: Feb 10 '13
Conditional evaluation component in mvvm
Children Binding : UiException Callable only in the event listener
Attributes in macro was not updated after notifyChange
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 tab box - delay @load until tab pane displayed?
mvvm, load or save with after or before for seach command
how to fire an event when a variable value loaded through VM
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 )editI 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