Announcement Announcement Module
Collapse
No announcement yet.
Stripping Whitespace from a Command's fields Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    How about placing it in the setter?

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

    Comment


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

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

      Comment

      Working...
      X