You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mi...@wellsfargo.com on 2004/12/16 23:11:09 UTC
String with digits to Long, verse String w/ digits and commas to Long
I have a form field that I want to be a number in the DB, but the user can add digits, or digits with commas into.
So 1000 is the same at 1,000 on the ui.
My question is, will struts convert "1,000" to 1000L just as it will convert "1000" to 1000L?
--------------------
Mick Knutson
Wells Fargo Business Direct Information Systems
(415) 222-1020
"This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation."
--------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: String with digits to Long,
verse String w/ digits and commas to Long
Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: <Mi...@wellsfargo.com>
> I have a form field that I want to be a number in the DB,
> but the user can add digits, or digits with commas into.
> So 1000 is the same at 1,000 on the ui.
> My question is, will struts convert "1,000" to 1000L
> just as it will convert "1000" to 1000L?
Struts doesn't do conversions-- BeanUtils (a Jakarta Commons project) does.
Use a String in the Form itself, that way you can validate and re-display
incorrect data. Then use BeanUtils to copy the data from the form to some
object that you hand to the database. If BeanUtils doesn't convert the way
you want it to, you can write your own Converter and register it.
Does a number with commas pass validation for a long?
--
Wendy Smoak
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org