Take a look at the validator example application that comes in the Struts
distribution. There is an example of referencing the variable so you don't
define it twice.

In your case, it should be:
    <field property="userName" depends="required,minlength,maxlength">
      <arg0 key="label.userName"/>
      <arg1 key="${var:minlength}" resource="false"/>
      <arg2 key="${var:maxlength}" resource="false"/>
      <var>
        <var-name>minlength</var-name>
        <var-value>4</var-value>
      </var>
      <var>
        <var-name>maxlength</var-name>
        <var-value>12</var-value>
      </var>
    </field>

Steve

> -----Original Message-----
> From: Fenderbosch, Eric [mailto:[EMAIL PROTECTED]
> Sent: September 30, 2003 1:53 PM
> To: Struts Users Mailing List
> Subject: RE: Application Resources & Error messages
>
>
> I just came to the same conclusion a coupld of minutes ago.
>
> Now the question is, if I define both a minlength and a
> maxlength, do I have to define it like this:
>
>       <field property="userName" depends="required,minlength,maxlength">
>         <arg0 key="label.userName"/>
>         <arg1 key="4" resource="false"/>
>         <arg2 key="12" resource="false"/>
>         <var>
>           <var-name>minlength</var-name>
>           <var-value>4</var-value>
>         </var>
>         <var>
>           <var-name>maxlength</var-name>
>           <var-value>12</var-value>
>         </var>
>       </field>
>
> And then make my error messages like this:
> errors.minlength={0} can not be less than {1} characters.
> errors.maxlength={0} can not be greater than {2} characters.
>
> It seems a little silly that I have to specify "4" and "12" twice
> in the validator.  Shouldn't it just pass the <var-value>
> argument along to the error message?  Is there a easy way to do that?
>
> -----Original Message-----
> From: Chen, Gin [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 30, 2003 16:44
> To: 'Struts Users Mailing List'
> Subject: RE: Application Resources & Error messages
>
>
> This has to do with your validation xml.
> You should have an arg0 and an arg1 that represent {0} and {1} in your
> message respectively.
> Check how you have it defined.
> -Tim
>
> -----Original Message-----
> From: Fenderbosch, Eric [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 30, 2003 4:11 PM
> To: Struts Users Mailing List
> Subject: RE: Application Resources & Error messages
>
>
> Arrrrgh!
> I just didn't have it in the right location.  It was in the package
> structure alright, just in the war root, not WEB-INF/classes.
>
> Now, however, I'm getting this:
> User name can not be less than null characters.
>
> Why doesn't it know how many characters?
>
> -----Original Message-----
> From: Fenderbosch, Eric
> Sent: Tuesday, September 30, 2003 15:56
> To: [EMAIL PROTECTED]
> Subject: Application Resources & Error messages
>
>
> I'm confused on how error messages work.  I've created a properties file
> TrackMessageResource.properties in the proper package structure and
> specified it in my struts-config like this:
> <message-resources
>   null="false"
>   parameter="com.*****.cc.track.struts.TrackMessageResources"/>
>
> I'm using the validator plugin and it is returning error messages like:
> ???en_US.errors.minlength???
>
> In TrackMessageResource.properties I have:
> errors.minlength={0} can not be less than {1} characters.
>
> This application is not going to be I18N so I only want/need one message
> resource file.  I don't understand why validator can't find the correct
> error message.  Any help would be appreciated.
>
> Thanks.
>
> Eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to