Hi Bill, 

Do you think we could support '-' for map key? 

-- 
Weinan Li



On Tuesday, November 27, 2012 at 12:45 AM, John Reiter wrote:

> Hello,
> 
> I'm having an issue with RESTEasy 2.3.4 with using @Form/@FormParam 
> annotations to set values of a Map that uses UUIDs for its keys.  My classes 
> basically look like this:
>     
>     @Controller
>     @Path( "/test" )
>     public class MyController
>     {
>         @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
>         @POST
>         public ModelAndView setAssignments( @Form final MyForm myForm ) 
>                 throws URISyntaxException
>         { ... }
>     }
> 
>     public class MyForm
>     {
>         @Form( prefix = "myMap" )
>         private Map<String, Foo> myMap = Maps.newHashMap();
>     }
> 
>     public class Foo
>     {
>         @FormParam( "bar" )
>         public void setBar( final String bar )
>        { ... }
>     }
> 
> The request parameters that get submitted look like this:
> 
> myMap[75736572-3100-505f-dac0-0000000745b8].bar
> myMap[b794c4a0-14b7-0130-c2da-20c9d04983db].bar
> etc.
> 
> The Foo.bar properties never end up being set.  Stepping through with a 
> debugger, the problem occurs in 
> AbstractCollectionFormInjector.findMatchingPrefixesWithNoneEmptyValues(): 
> that method tries to find keys in the map that match a regex.  In this case, 
> the regex is defined in MapFormInjector:
> 
>    public MapFormInjector(Class collectionType, Class keyType, Class 
> valueType, String prefix, ResteasyProviderFactory factory)
>    {
>       super(collectionType, valueType, prefix, Pattern.compile("^" + prefix + 
> "\\[([a-zA-Z_]+)\\]"), factory);
>       keyInjector = new StringParameterInjector(keyType, keyType, null, 
> Form.class, null, null, new Annotation[0], factory);
>    }
> 
> And only allows alpha characters and underscores, which is obviously why my 
> map isn't being populated.  I'm working around this right now by mapping 
> temporary, alpha-only keys to the real ones and using those in my form then 
> replacing them after the form is submitted.  Is there a way to get this regex 
> changed to be something a little more lenient?  Really, is there any reason 
> to disallow anything other than maybe brackets?
> 
> If you want me to enter a JIRA issue for this, let me know.
> 
> Thanks,
> John
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> 
> _______________________________________________
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net 
> (mailto:Resteasy-users@lists.sourceforge.net)
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
> 
> 


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
VERIFY Test and improve your parallel project with help from experts 
and peers. http://goparallel.sourceforge.net
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to