From: John R. <joh...@gm...> - 2012-11-29 15:58:28
|
I know it's obvious from the regex, but it looks like map keys with numbers also wouldn't work right now (all I've tested is the case I outlined in my email though). John On Thu, Nov 29, 2012 at 10:41 AM, Bill Burke <bb...@re...> wrote: > I don't see a reason why this couldn't be fixed. > > > On 11/29/2012 8:33 AM, Weinan Li wrote: > >> 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**.**findMatchingPrefixesWithNoneEm** >>> ptyValues(): >>> 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<http://p.sf.net/sfu/zoho_dev2dev_nov> >>> ______________________________**_________________ >>> Resteasy-users mailing list >>> Resteasy-users@lists.**sourceforge.net<Res...@li...> >>> <mailto:Resteasy-users@lists.**sourceforge.net<Res...@li...> >>> > >>> https://lists.sourceforge.net/**lists/listinfo/resteasy-users<https://lists.sourceforge.net/lists/listinfo/resteasy-users> >>> >> >> > -- > Bill Burke > JBoss, a division of Red Hat > http://bill.burkecentral.com > |