You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ben Kafka <be...@communitect.com> on 2002/03/11 18:59:43 UTC

Struts Validator changing the "key" in the validator.xml

Was wondering if there is a way to access a unique string to display for a
"required" error in the javascript function under validator-rules.xml. Right
now the following happens:
If in the validator.xml file I specify the <arg0
key=regform.firstname.displayname" > it is
used by both the "required" and "mask" javascript functions to display a
canned error like
Firstname is invalid.
Firstname required.

How can I differentiate these. For instance I would like to say..
Firstname in invalid because only upper and lower case letters are allowed.

In the Application resources properties currently I have "{0} is invalid"
for my "errors.invalid" tag. What I would like to have is "{0} is invalid
because {1}" but I don't know how to define the {1} in the validation.xml
and validation-rules.xml.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Struts Validator changing the "key" in the validator.xml

Posted by Ben Kafka <be...@communitect.com>.
Thanks Dave!

-----Original Message-----
From: David Winterfeldt [mailto:dwinterfeldt@yahoo.com]
Sent: Monday, March 11, 2002 11:21 AM
To: Struts Users Mailing List
Subject: Re: Struts Validator changing the "key" in the validator.xml



There are some examples here.
http://home.earthlink.net/~dwinterfeldt/overview.html#i18n

> In the Application resources properties currently I
> have "{0} is invalid"
> for my "errors.invalid" tag. What I would like to
> have is "{0} is invalid
> because {1}" but I don't know how to define the {1}
> in the validation.xml
> and validation-rules.xml.

<field property="lastName"
              depends="required,mask">
   <arg0 key="registrationForm.lastname.displayname"/>

   <arg1 name="mask"
key="registrationForm.lastname.becauseMessage"/>
   <var>
      <var-name>mask</var-name>
      <var-value>^[a-zA-Z]*$</var-value>
   </var>
</field>

or you can override the default message:

<field property="lastName"
              depends="required,mask">
   <msg name="mask"
key="registrationForm.lastname.maskmsg"/>
   <arg0 key="registrationForm.lastname.displayname"/>

   <var>
      <var-name>mask</var-name>
      <var-value>^[a-zA-Z]*$</var-value>
   </var>
</field>

David

--- Ben Kafka <be...@communitect.com> wrote:
> Was wondering if there is a way to access a unique
> string to display for a
> "required" error in the javascript function under
> validator-rules.xml. Right
> now the following happens:
> If in the validator.xml file I specify the <arg0
> key=regform.firstname.displayname" > it is
> used by both the "required" and "mask" javascript
> functions to display a
> canned error like
> Firstname is invalid.
> Firstname required.
>
> How can I differentiate these. For instance I would
> like to say..
> Firstname in invalid because only upper and lower
> case letters are allowed.
>
> In the Application resources properties currently I
> have "{0} is invalid"
> for my "errors.invalid" tag. What I would like to
> have is "{0} is invalid
> because {1}" but I don't know how to define the {1}
> in the validation.xml
> and validation-rules.xml.
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts Validator changing the "key" in the validator.xml

Posted by David Winterfeldt <dw...@yahoo.com>.
There are some examples here.
http://home.earthlink.net/~dwinterfeldt/overview.html#i18n

> In the Application resources properties currently I
> have "{0} is invalid"
> for my "errors.invalid" tag. What I would like to
> have is "{0} is invalid
> because {1}" but I don't know how to define the {1}
> in the validation.xml
> and validation-rules.xml.

<field property="lastName" 
              depends="required,mask"> 
   <arg0 key="registrationForm.lastname.displayname"/>

   <arg1 name="mask"
key="registrationForm.lastname.becauseMessage"/> 
   <var>
      <var-name>mask</var-name>
      <var-value>^[a-zA-Z]*$</var-value>
   </var>
</field> 

or you can override the default message:

<field property="lastName" 
              depends="required,mask"> 
   <msg name="mask"
key="registrationForm.lastname.maskmsg"/> 
   <arg0 key="registrationForm.lastname.displayname"/>

   <var>
      <var-name>mask</var-name>
      <var-value>^[a-zA-Z]*$</var-value>
   </var>
</field> 

David

--- Ben Kafka <be...@communitect.com> wrote:
> Was wondering if there is a way to access a unique
> string to display for a
> "required" error in the javascript function under
> validator-rules.xml. Right
> now the following happens:
> If in the validator.xml file I specify the <arg0
> key=regform.firstname.displayname" > it is
> used by both the "required" and "mask" javascript
> functions to display a
> canned error like
> Firstname is invalid.
> Firstname required.
> 
> How can I differentiate these. For instance I would
> like to say..
> Firstname in invalid because only upper and lower
> case letters are allowed.
> 
> In the Application resources properties currently I
> have "{0} is invalid"
> for my "errors.invalid" tag. What I would like to
> have is "{0} is invalid
> because {1}" but I don't know how to define the {1}
> in the validation.xml
> and validation-rules.xml.
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>