Results 1 to 2 of 2

Thread: Forcing Uppercase in Form Field

  1. #1
    Join Date
    Sep 2004
    Location
    Vancouver, BC, Canada
    Posts
    135

    Default Forcing Uppercase in Form Field

    I have a requirement that a certain String property in one of my domain objects must always have only uppercase characters. Rather than using a regexp constraint like regexp("[A-Z]*", "uppercaseAlphabetic") I would prefer that lowercase letters be automatically converted to uppercase letters as they are typed.

    In the past when I was using raw Swing (i.e. not Spring RCP), I handled this problem by deriving from JTextField and overriding createDefaultModel(), making that method return a model that forced uppercase in insertString(). It worked great.

    For Spring RCP, I suppose I could reuse my JTextField and register it as the property editor for the property in question. However, I was wondering if this "force uppercase" feature is already implemented somewhere within Spring RCP. Is it?
    Cheers,
    Joe
    "All your bean are belong to us" - Spring Framework's IOC Container

  2. #2
    Join Date
    Sep 2004
    Location
    Vancouver, BC, Canada
    Posts
    135

    Default

    Similar to the "force uppercase" feature noted above, it would also be nice to have a "beep on max length" feature. For example, let's say I have a property that has a maximum length of 25 characters. Currently with Spring RCP, such a max length constraint is implemented by binding this constraint to a property with: maxLength(25). When the user types in more than 25 characters, the dialog's message area displays a message like "<property> must be no more than 25 characters". That message gives good feedback but the JTextField happily echoes every additional character beyond 25. Thus, to correct the property value, the user must backspace or delete the additional characters.

    As an option instead of a maxLength constraint like above, it would be nice if the system could beep and then reject the 26th character (i.e not echo the 26th character in the JTextField). Like the uppercase example above, I could implement this feature by deriving from JTextField and registering my JTextField as a property editor. However, it would be nice if this feature was built into Spring RCP.

    Thinking about this a little bit further, I reasoned that if the system beeps, it should not also show the message "<property> must be no more than 25 characters" because the dialog would have no way of knowing when to remove the message (currently it removes it when you delete the 26th character but with above beep feature, there would be no 26th character to delete!).
    Cheers,
    Joe
    "All your bean are belong to us" - Spring Framework's IOC Container

Similar Threads

  1. Replies: 3
    Last Post: Jun 8th, 2010, 03:27 AM
  2. Replies: 4
    Last Post: Jun 13th, 2006, 05:21 PM
  3. Not updating a form field on setFormObject()?
    By SCWells72 in forum Swing
    Replies: 13
    Last Post: Aug 28th, 2005, 12:43 PM
  4. Replies: 7
    Last Post: Feb 21st, 2005, 11:33 PM
  5. How to mark a form field as required???
    By Christian in forum Web
    Replies: 4
    Last Post: Sep 21st, 2004, 02:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •