Wicket
  1. Wicket
  2. WICKET-4356

StringValueConversionException should not be thrown when requesting a conversion on StringValue with a default value

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.3
    • Fix Version/s: 1.5.5, 6.0.0-beta1
    • Component/s: wicket
    • Labels:
      None

      Description

      In my application I need to get current page parameter from PageParameters

      so I use this code

      PageParameters parameters = ...
      int currentPage = parameters.get("page").toInt(1);

      It works good when "page" parameter contains an Integer value or is null, but when it contains a non numeric value it throws an exception StringValueConversionException.

      I would expect a little bit different behaviour. Why not to return DEFAULT value when StringValueConversionException is thrown? I think it is more secure and saves many lines of code, because you do not need to check that StringValue is really a string containing only numeric characters.

        Activity

        Hide
        Robert McGuinness added a comment -

        i ran into this issue as well, kinda wish the api would fail silently upon conversion and return defaults. Ex:

        http://wicket-stateless.herokuapp.com/?counter=8 (works)

        but I forgot to check for non ints so the following will fail (will be fixed soon)

        http://wicket-stateless.herokuapp.com/?counter=fails

        Show
        Robert McGuinness added a comment - i ran into this issue as well, kinda wish the api would fail silently upon conversion and return defaults. Ex: http://wicket-stateless.herokuapp.com/?counter=8 (works) but I forgot to check for non ints so the following will fail (will be fixed soon) http://wicket-stateless.herokuapp.com/?counter=fails
        Hide
        Martin Grigorov added a comment -

        The behavior of all methods "toXyz(default)" has been changed as requested.
        Discussion: http://markmail.org/thread/4brd7ywrxt3vcyo2

        Show
        Martin Grigorov added a comment - The behavior of all methods "toXyz(default)" has been changed as requested. Discussion: http://markmail.org/thread/4brd7ywrxt3vcyo2

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Sergei Sizov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development