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:

    @Path( "/test" )
    public class MyController
        @Consumes( MediaType.APPLICATION_FORM_URLENCODED )
        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:


The Foo.bar properties never end up being set.  Stepping through with a
debugger, the problem occurs in
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.

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!
Resteasy-users mailing list

Reply via email to