jastrachan | 14 Jun 15:29 2004
Picon

Re: auto bean filling

On 14 Jun 2004, at 14:48, Alan Wood wrote:
> Is it possible to do this kind of thing in groovy:
>
> MyBean filledBean = new MyBean(*:map)
>
> where MyBean is obvously a java bean with get and sets and the map is 
> say a HashMap full of name value objects with names corresponding to 
> the bean fields.
>
> Thus the corresponding map objects get loaded into the bean.
>
> a bit like JSPs <jsp:setProperty  name="filledBean" property="*"/>
>
> this is very usefull for html form filling among other things.
>
> it could even be extended to use regex rather than just '*' but that 
> might be overkill

FWIW I think just using

MyBean filledBean = new MyBean(map)

would work, provided there's no matching constructor for MyBean which 
takes the map parameter.

James
-------
http://radio.weblogs.com/0112098/


Gmane