You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by xianwinwin <xi...@gmail.com> on 2008/03/26 21:06:15 UTC

how to do: a double validation?

hi there,

say a user inputs a value for a double field (say amount of money); the
value should be a double (eg, 53.23) 

Question: if the user enters something like ABCD how can I provide the error
message? 
I would like to do that with annotation? (say....you enter an invalid
value...)


what type of validation whould that be?!?!?!

@Validations(
            stringLengthFields ={
            					 @StringLengthFieldValidator(type = ValidatorType.SIMPLE,
trim = true, minLength="1" , fieldName = "age", 	message = "you forgot this
one!!!! ")
            					}
		
    )  
	public String updatePolicy()
	{
		 // do something here
        }
-- 
View this message in context: http://www.nabble.com/how-to-do%3A-a-double-validation--tp16314886p16314886.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how to do: a double validation?

Posted by Dave Newton <ne...@yahoo.com>.
--- xianwinwin <xi...@gmail.com> wrote:
> yes, this works for checking the range but I wish to check the validity of
> the field. meaning, I'd like to provide my error message in case the user 
> gave wrong input. how do I do that?

That would depend on what "wrong input" means.

If the existing validators do not provide the checking you need you can
create your own, register it via XML configuration, and use the
@CustomValidator (I think) annotation.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how to do: a double validation?

Posted by xianwinwin <xi...@gmail.com>.
Thank you Dave!!!
yes, this works for checking the range but I wish to check the validity of
the field.
meaning, I'd like to provide my error message in case the user gave wrong
input. how do I do that?
Thank you again



newton.dave wrote:
> 
> --- xianwinwin <xi...@gmail.com> wrote:
>> 
>> say a user inputs a value for a double field (say amount of money); the
>> value should be a double (eg, 53.23) 
>> 
>> Question: if the user enters something like ABCD how can I provide the
>> error message? 
>> I would like to do that with annotation? (say....you enter an invalid
>> value...)
>> 
>> 
>> what type of validation whould that be?!?!?!
> 
> Er... a Double validation?
> 
> http://struts.apache.org/2.x/docs/doublerangefieldvalidator-annotation.html
> 
> Dave
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/how-to-do%3A-a-double-validation--tp16314886p16316211.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: how to do: a double validation?

Posted by Dave Newton <ne...@yahoo.com>.
--- xianwinwin <xi...@gmail.com> wrote:
> 
> say a user inputs a value for a double field (say amount of money); the
> value should be a double (eg, 53.23) 
> 
> Question: if the user enters something like ABCD how can I provide the
> error message? 
> I would like to do that with annotation? (say....you enter an invalid
> value...)
> 
> 
> what type of validation whould that be?!?!?!

Er... a Double validation?

http://struts.apache.org/2.x/docs/doublerangefieldvalidator-annotation.html

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org