• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

maxlength for customer id column

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at what formatted text fields can do for you? Especially the javax.swing.text.MaskFormatter class?

Regards, Andrew
 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

Originally posted by Andrew Monkhouse:
Have you looked at what formatted text fields can do for you? Especially the javax.swing.text.MaskFormatter class?

Regards, Andrew

 
Tim Fernandez
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any thoughts on how to implement this one?
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic