You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Juan Carlos Serrano <ju...@gmail.com> on 2008/01/31 13:38:56 UTC
[S2] problems with validations
Hi,
i have this code when i get a error
if( person.getNumId() == null || person.getNumId().trim().length() <
9 ) {
String[] pars = {"8"};
this.addFieldError( "field.doc" , this.getText( "
error.val.minlength" , pars ) );
}
where "field.doc" it is a key with a string associate in a resource file:
field.doc=Identification.
In my errors.properties file i have a error description by "
error.val.minlength":
error.val.minlength=Needs to be {0} characters long at least, for
"${getText(fieldName)}"
but in my pages i get: Needs to be 8 characters long at least, for "".
Why can not i get the string "Identification" associated with the string "
field.doc"?
In the other hand, if i put the validation into xml file like:
<field name="doc">
<field-validator type="stringlength">
<param name="minLength">8</param>
<param name="trim">true</param>
<message key="error.val.minlength"/>
</field-validator>
</field>
i get: "Needs to be {0} characters long at least, for ""
How can I associated this validation with the key "field.doc" by get
"Identification" througth ${getText(fieldName)} if my field name for this
textfield it is different that key associated it?, and how can i get the
param 8 from this xml sintax?
Sorry for my english, thanks a lot for your help.