Wicket
  1. Wicket
  2. WICKET-4309

StringValueConversionException for correct situation

    Details

      Description

      StringValue.toOptionalLong() produces org.apache.wicket.util.string.StringValueConversionException if empty string was passed.
      Let me suggest, that this behavior should be changes for all toOptionalXXX methods except getOptionalString method.

      The problem in inner code:

      The problem in following code:

      public final Long toOptionalLong() throws StringValueConversionException

      { return (text == null) ? null : toLongObject(); }

      Should be something like this:

      The problem in following code:

      public final Long toOptionalLong() throws StringValueConversionException

      { return Strings.isEmpty() ? null : toLongObject(); }

      But there is another problem: what to do if incorrect param was passed - for example "abc" for parameter of Long type?

      1. WICKET-4309.patch
        3 kB
        Andrea Del Bene

        Activity

        Ilia Naryzhny created issue -
        Hide
        Andrea Del Bene added a comment -

        The discussion for this issue is here: http://mail-archives.apache.org/mod_mbox/wicket-users/201111.mbox/%3CCAEvAQhOFBzXdnabkeYOJKA0iDt4abHWnGqEbsXaYoYsfaXT25g@mail.gmail.com%3E

        I've attached a patch which applies proposed changes to all toOptionalXXX methods except toOptionalString.

        Show
        Andrea Del Bene added a comment - The discussion for this issue is here: http://mail-archives.apache.org/mod_mbox/wicket-users/201111.mbox/%3CCAEvAQhOFBzXdnabkeYOJKA0iDt4abHWnGqEbsXaYoYsfaXT25g@mail.gmail.com%3E I've attached a patch which applies proposed changes to all toOptionalXXX methods except toOptionalString.
        Andrea Del Bene made changes -
        Field Original Value New Value
        Attachment WICKET-4309.patch [ 12509351 ]
        Hide
        Martin Grigorov added a comment -

        Patch applied.
        Thanks, Andrea!

        Show
        Martin Grigorov added a comment - Patch applied. Thanks, Andrea!
        Martin Grigorov made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Martin Grigorov [ mgrigorov ]
        Fix Version/s 1.5.4 [ 12319051 ]
        Fix Version/s 6.0.0 [ 12315431 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Ilia Naryzhny
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development