Re: [Resteasy-users] @Form and non-alpha map keys

2012-11-29 Thread Bill Burke
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 MapString, 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-000745b8].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


-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

--
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


Re: [Resteasy-users] @Form and non-alpha map keys

2012-11-29 Thread Weinan Li


-- 
Weinan Li



On Thursday, November 29, 2012 at 11:41 PM, Bill Burke wrote:

 I don't see a reason why this couldn't be fixed.
 
 


Cool! John, could you please create a JIRA for this and provide me the link so 
I could assign it to me? Please describe your requirements in detail and I'll 
work on it.
 
 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 MapString, 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-000745b8].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)
   mailto:Resteasy-users@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/resteasy-users
   
  
  
 
 
 -- 
 Bill Burke
 JBoss, a division of Red Hat
 http://bill.burkecentral.com
 
 


--
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


Re: [Resteasy-users] @Form and non-alpha map keys

2012-11-29 Thread Weinan Li


-- 
Weinan Li



On Thursday, November 29, 2012 at 11:58 PM, John Reiter wrote:

 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).
 
Hi John ,could you please sum up your problem and create a JIRA? I'll work on 
it, thanks! 
 John
 
 On Thu, Nov 29, 2012 at 10:41 AM, Bill Burke bbu...@redhat.com 
 (mailto:bbu...@redhat.com) 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 MapString, 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-000745b8].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)
mailto:Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users
   
  
  -- 
  Bill Burke
  JBoss, a division of Red Hat
  http://bill.burkecentral.com
 

--
Keep yourself connected to Go Parallel: 
TUNE You got it built. Now make it sing. Tune shows you how.
http://goparallel.sourceforge.net___
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users