Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1706

org.apache.wicket.util.lang.Objects.convertValue returns null if it cannot convert the value

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.3.3, 1.4-M2
    • 1.3.4, 1.4-M3
    • wicket
    • None
    • any

    Description

      In the javadoc comment of the method it says that this method should return the value given as parameter if the value cannot be converted to the given type, but actually it returns null if it cannot convert the value.

      I had a problem with a TextField which had a model value of type java.io.Serializable and I had unfortunately not defined a special converter for the text field so it used org.apache.wicket.util.convert.ConverterLocator.DefaultConverter.convertToObject to convert to the object type. convertToObject uses Objects.convertValue so whenever model object was updated it was set to null. When retrieved from the model, model object was properly shown in the TextField so I had no idea why the value could not be properly setted but only getted.

      In many cases it would probably help if the Objects.convertValue did what it promises in javadoc (returns the value unconverted), but how about throwing exception (at some method) if the converter does not know how to convert some kind of objects? This would make it a lot easier to spot the kind of mistakes I had made.

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            mika Mika Salminen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: