• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Validation.xml

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am new in the struts validation framework and some question. I just checking a code in which there is a jsp that contains the a text box and submit buttion
In the validation.xml the entry like this

<form name = "abc">
<field property = "username"
depends = "required"
arg0 key = "update.user"
arg1 key = "${var.maxlength}" name = maxlength resource = "false"/>
</form>

Now my question is that here in the depend we are using the required , so what is the use of meaning of key = ${var:maxlength} here

One more thing it is mentioned that for a single validation method we have up to four arguments . What is the use of four arguments here

Thanks in advance for your prompt answer
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is an area of Struts that seems like it could have better documentation. If you go to this page you can see examples of all the built in validation rules: http://struts.apache.org/1.2.4/userGuide/dev_validator.html

You will notice that the "required" example does not have an arg1 value. My understanding is that the arg0, arg1, arg2, etc. values are just used to replace the values in the message. The default message for required is:

errors.required={0} is required.

I suppose that if you changed this message then maybe you would want to supply an arg1 value. I suspect that in your case somebody removed "maxlength" from the depends list but did not update the list of arg values.

I am not sure about your "four argument" validation rule. The only default one that has 3 arguments (arg0 - arg2) is the range message:

errors.range={0} must be between {1} and {2} inclusive.

- Brent
 
reply
    Bookmark Topic Watch Topic
  • New Topic