Results 1 to 2 of 2

Thread: Long CustomEditor

  1. #1
    Join Date
    Mar 2005
    Posts
    5

    Default Long CustomEditor

    Hello,

    Seems that the LongCustomEditor doesn't convert correct strings to long when the string passed have a blank character.

    I think that is not he correct behaviour and the string has to be trimmed before trying to convert to long.

    I think i can extend the editor form spring an register the editor to achieve the desired effect but i think this is a thing that has to do the core project of spring.

    Thank you for your time.

    exception:
    ------------
    nested exception is
    org.springframework.beans.PropertyAccessExceptions Exception:
    PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions
    are: [org.springframework.beans.TypeMismatchException: Failed to convert
    property value of type [java.lang.String] to required type [long] for
    property 'repeatInterval'; nested exception is
    java.lang.NumberFormatException: For input string: "30000 "]
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property
    value of type [java.lang.String] to required type [long] for
    property 'repeatInterval'; nested exception is
    java.lang.NumberFormatException: For input string: "30000 "
    java.lang.NumberFormatException: For input string: "30000 "
    at java.lang.NumberFormatException.forInputString
    (NumberFormatException.java:48)
    at java.lang.Long.parseLong(Long.java:403)
    at java.lang.Long.valueOf(Long.java:509)
    at sun.beans.editors.LongEditor.setAsText(LongEditor. java:24)
    at
    org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary
    (BeanWrapperImpl.java:962)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue
    (BeanWrapperImpl.java:778)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue
    (BeanWrapperImpl.java:684)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue
    (BeanWrapperImpl.java:825)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues
    (BeanWrapperImpl.java:852)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues
    (BeanWrapperImpl.java:841)
    at
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.ap
    plyPropertyValues(AbstractAutowireCapableBeanFacto ry.java:863)

  2. #2
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    Thanks for spotting that. Actually the problem here is twofold. One is that out NumberUtils doesn't trim Strings and the other that in this case the core Java LongEditor is being used.

    I'm going to swap all primitive numbers to use out CustomNumberEditor and I will make NumberUtils (which does the actual conversion) trim Strings before parsing them.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

Similar Threads

  1. Replies: 2
    Last Post: Sep 22nd, 2005, 04:11 PM
  2. Replies: 3
    Last Post: Sep 22nd, 2005, 10:14 AM
  3. Binding Long Values with CustomNumberEditor
    By chichirico in forum Web
    Replies: 0
    Last Post: Jun 21st, 2005, 11:02 AM
  4. Long or long ????
    By mia in forum Web
    Replies: 2
    Last Post: May 5th, 2005, 10:02 AM
  5. Long lived locks
    By aaime in forum Swing
    Replies: 3
    Last Post: Mar 11th, 2005, 07:54 PM

Posting Permissions

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