You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (Resolved) (JIRA)" <ji...@apache.org> on 2012/01/31 12:30:10 UTC

[jira] [Resolved] (WICKET-4356) StringValueConversionException thrown when calling toInt(final int defaultValue) on StringValue. Why not to return the default value?

     [ https://issues.apache.org/jira/browse/WICKET-4356?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov resolved WICKET-4356.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 6.0.0
                   1.5.5
         Assignee: Martin Grigorov

The behavior of all methods "toXyz(default)" has been changed as requested.
Discussion: http://markmail.org/thread/4brd7ywrxt3vcyo2
                
> StringValueConversionException thrown when calling toInt(final int defaultValue) on StringValue. Why not to return the default value?
> -------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4356
>                 URL: https://issues.apache.org/jira/browse/WICKET-4356
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.5.3
>            Reporter: Sergei Sizov
>            Assignee: Martin Grigorov
>             Fix For: 1.5.5, 6.0.0
>
>
> 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.
>  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira