Adding @FormParam("") to a FormBean method parameter is all what is needed



Cheers, Sergey

On Mon, Apr 18, 2011 at 4:09 PM, Benson Margulies <[email protected]>wrote:

> Sergey,
>
> Here was my brainwave:
>
> Consider a bean-pattern class with ...
>
>       class FormBean {
>          void setFrog(String frog) { ... }
>          void setSnake(String snake) { ... }
>       }
>
> And then a form with fields named 'frog' and 'snake'. What sort of
> JAX-RS device would we need to write that could map the form field
> names to the bean accessors? If the function was, perhaps,
> setSnake(String[] snakes), then it would take all of the multiple
> values if there were multiple values.
>
>
>
> On Mon, Apr 18, 2011 at 4:23 AM, Sergey Beryozkin <[email protected]>
> wrote:
> > Hi Benson
> >
> > Ideally @Consumes is specified, but it is not strictly required.
> > If it is not then providers will be asked in turn if they can
> > handle reading into a given object,
> > JAXBElementProvider will say yes if its class is XmlRootElement
> > annotated/etc.
> >
> > In your case, it is a form submission, so given that no @Consumes is set,
> > all providers are checking the bean and just don't accept it.You can add
> a
> > @FormParam("") annotatation and it will fix it.
> >
> > Adding @Consumes(MediaType.APPLICATION_FORM_URLENCODED) should've fixed
> it
> > too, but it won't, unless you use MultivaluedMap as a method parameter.
> > Would make sense enhancing a form provider a bit - will look into it a
> bit
> > later
> >
> > Sergey
> >
> >
> > On Sun, Apr 17, 2011 at 10:40 PM, Benson Margulies <
> [email protected]>wrote:
> >
> >> I am really not understanding why the page of examples shows a
> >> function that takes a single bean argument and has @POST on it. Is the
> >> idea here that someone would POST with content-type, oh, XML?
> >>
> >> On Sun, Apr 17, 2011 at 5:25 PM, Benson Margulies <
> [email protected]>
> >> wrote:
> >> > So, using some jquery magic, I'm sending a POST, and getting back a
> >> > 415. I have no @Consumes annotation at all. I've specified a bean as
> >> > the parameter to the method, on the theory that the form params will
> >> > be reflected into the bean. How many things have I got wrong here?
> >> >
> >>
> >
>



-- 
Sergey Beryozkin

Application Integration Division of Talend <http://www.talend.com/>
http://sberyozkin.blogspot.com

Reply via email to