Hi Wicket team:

I'd like to be able to call getInt(name, default) and not have to worry
about catching exceptions.  If the number can't be parsed, just return the
default.

I have a utility method which I use:

    public static int getInt(PageParameters params, String name, int def)
    {
        try
        {
            return params.getInt(name, def);
        }
        catch (StringValueConversionException ignored)
        {
            return def;
        }
    }

Basically for my bookmarkable pages, I don't care if a user mucks with the
URL - this would let me default to something reasonable.

It would be nice if there were a comparable method on PageParameters ...
like getIntSafe(name, def) or some something similar (and for other
number-based getters).

In addition, it would be nice to have a getInteger() object method that
returns null if not defined or an Integer object.  The way it is now, I have
to pick a default value that I assume won't ever be valid (usually -1). 
There are valid use cases where null is an expected value.

-Doug

-Doug


-- 
View this message in context: 
http://www.nabble.com/PageParameters-request-for-enhancement-tp16853545p16853545.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to