Results 1 to 3 of 3

Thread: Stripping Whitespace from a Command's fields

  1. #1
    Join Date
    Aug 2004
    Location
    Toronto, ON, Canada
    Posts
    101

    Default Stripping Whitespace from a Command's fields

    What is the proper way of stripping leading and trailing white space from fields in a command? Right now i do a command.setBlah(command.getBlah().trim()) on every field in onBind but that doesn't look like the correct way.

    Is there a 'Spring Approved' method for this?

    S.

  2. #2
    Join Date
    Aug 2004
    Location
    Boston MA
    Posts
    27

    Default

    How about placing it in the setter?

    Code:
    public class Monkey {
      private String name;
    
      public void setName(String name) {
        this.name = name.trim();
      }
    }

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    org.springframework.beans.propertyeditors.StringTr immerEditor, but you have to register it.

    empty strings get converted into null in the underlying command object.

Similar Threads

  1. Replies: 2
    Last Post: Jul 14th, 2007, 09:05 AM
  2. Replies: 6
    Last Post: Sep 24th, 2006, 11:58 AM
  3. Replies: 2
    Last Post: Aug 4th, 2006, 01:37 PM
  4. Replies: 1
    Last Post: Sep 22nd, 2005, 04:42 AM
  5. Replies: 2
    Last Post: Oct 8th, 2004, 04:29 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
  •