| Author |
maxlength for customer id column
|
Tim Fernandez
Ranch Hand
Joined: Aug 31, 2005
Posts: 65
|
|
Hi Everyone, I would like to limit the number of string that can be entered in the customer id field. In this case, i will only allow 8 characters since this is what the urly bird specification requires. ANy thoughts on how I can implement this one? regards, tim
|
 |
Jason Moors
Ranch Hand
Joined: Dec 04, 2001
Posts: 188
|
|
In your create and update methods you could compare the length of the String provided against the metadata for each field. Then if a field is too long you can either throw an exception or you could choose to truncate the string, i.e only insert the x leftmost characters. Jason.
|
 |
ak pillai
author
Ranch Hand
Joined: Feb 11, 2006
Posts: 288
|
|
|
Why not have an InputValidator class and restrict the length. This way, you only need to do it in one location, not in every SQL statements
|
java j2ee job interview questions with answers | Learn the core concepts and the key areas
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10816
|
|
Have you looked at what formatted text fields can do for you? Especially the javax.swing.text.MaskFormatter class? Regards, Andrew
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
Tim Fernandez
Ranch Hand
Joined: Aug 31, 2005
Posts: 65
|
|
Hi Everyone, I'm sorry about the confusion. I am entering the customer id in the cell in the table. So i do not think Maskformatter will help me. So I am wondering if there is something in the cell that can limit the number of characters you can enter. regards, tim
|
 |
Tim Fernandez
Ranch Hand
Joined: Aug 31, 2005
Posts: 65
|
|
|
Any thoughts on how to implement this one?
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10816
|
|
Hi Tim, I have condensed Sun's TableFTFEditDemo into what is possibly the smallest bit of code that I can use to discuss this - it creates a simple table where the third column will only allow integers between 100 and 999 to be entered. See how you go with this and/or see how you go with Sun's tutorials on the subject. If in doubt, you can always come back and ask questions Regards, Andrew
|
 |
 |
|
|
subject: maxlength for customer id column
|
|
|