[ 
https://issues.apache.org/jira/browse/WICKET-1596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12595032#action_12595032
 ] 

Doug Donohoe commented on WICKET-1596:
--------------------------------------

Also note that I made some other small changes to ValueMap to make use of JDK 
1.5 capabilities:

+ Use @Overrides where appropriate (not sure what Wicket coding standard is now 
that we'er on 1.5)
+ Used a for/each loop instead of an iterator

As an aside, I briefly looked into making ValueMap extend Map<Object, Object>, 
but that has issues.  Some places in the code assume a ValueMap is <String, 
String> and others assume it is <String, Object>.  Indeed, the ValueMap itself 
assumes keys can be non-objects.  Fixing this to be "correct" (IMHO <String, 
Object>) could be some work and a problem for end-users.

> New convenience methods for ValueMap
> ------------------------------------
>
>                 Key: WICKET-1596
>                 URL: https://issues.apache.org/jira/browse/WICKET-1596
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 1.4-M1
>         Environment: Any
>            Reporter: Doug Donohoe
>            Priority: Minor
>             Fix For: 1.4-M2
>
>         Attachments: valuemap.patch
>
>   Original Estimate: 0.17h
>  Remaining Estimate: 0.17h
>
> Methods to get values out of PageParameters (aka ValueMap) as first class 
> Objects (Boolean, Integer, Double, Long, Time, Duration) and to get the same 
> values as primitives if default values are provided without having to worry 
> about StringConversion exceptions.
> This allows one to do:
>   Integer id = params.getAsInteger("id") 
> And not have to worry if id is missing or someone tried to hack the query 
> string by passing in an non-numeric value.   Also, it allows you to check for 
> null without passing in a default value you hope never occurs in practice.
> Also allows you to get Enumerated values as page params.
> public enum TestEnum {
>         one, two, three
>     }
> ValueMap vm  = new ValueMap();
> vm.put("myenum",  "one");
> TestEnum test = vm.getAsEnum("myenum", TestEnum.class, TestEnum.three);
> I have this code done with test cases and a patch ready.  I'll see if I can 
> upload it after I create this issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to