On Nov 12, 2009, at 7:11 PM, Cemo Koc wrote:
> Forgive my ignorance but I could not understand @FormParamBean  
> section. As
> far as I know there is not such a annotation in jersey.
There is not, i was proposing that as part of a solution.
> Because of this I
> think that it should be implement by me now? If it so, I made  
> something
> similar to it. But it does not work for me. You can check what I  
> made in my
> first post.
>
Yes, unfortunately that will not work because of the current  
restrictions on the implementation of @FormParam.
Thinking out loud in the following....
Having thought about this some more ideally what i would like to  
achieve is:
   @GET
   public XXX get(@Inject MyParamBean b) { ... } // I am referring to  
Jersey's @Inject annotation.
which would replace:
   @GET
   public XXX get(@ResourceContext ResourceContext rc) { ...
      MyParamBean b = rc.get(MyParamBean.class);
   }
Then for forms ideally we could do the same like:
   @POST
   @Consumes("application/x-www-form-urlencoded")
   public XXX post(@Inject MyParamBean b) { ... }
The problem is there is a slight inconsistency in all this. Consider  
the following:
   public class Foo {
     public Foo(@Inject MyParamBean b) { ... }
     @GET
     public XXX get(@Inject MyParamBean b) { ... }
     @POST
     @Consumes("application/x-www-form-urlencoded")
     public XXX post(@Inject MyParamBean b);
   }
Currently we only know that form parameters are present when the POST  
method is called, but the reference to b in the constructor parameter  
should be the same as the parameter of the get or post (default life- 
cycle is per-request).
I am wondering if i should really relax things in this respect and go  
back on some of the things i said. The way we could do this is to  
buffer the request entity if it is of "application/x-www-form- 
urlencoded" and also parse the entity to an instance of Form from  
which @FormParam can operate. If there is no Form present we can throw  
an exception. Buffering would only occur if form parameters are  
accessed outside of the resource method, or cannot be detected from a  
resource method. However, i still do not like the fact form parameters  
could be processed from outside of the resource method.
Marc, if you got this far :-), what do you think?
Paul.