geronimo-xbean-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Austin <mail-li...@revolsys.com>
Subject Re: Using maps as properties for a bean
Date Thu, 04 Jan 2007 00:25:43 GMT
Not sure if that would be practical as there are many properties that
are maps so it could get confusing to create the document.

I've submitted a Jira issue, so will see if anyone can come up with a
solution or enhancement to support this.

Paul

On Sat, 2006-12-23 at 00:45 +0100, Guillaume Nodet wrote:

> I don't think this is supported :(
> You could use
> 
> <beans:beans
>  xmlns="http://ns.com/app/1.0"
>  xmlns:beans="http://www.springframework.org/schema/beans"
>  xmlns:util="http://www.springframework.org/schema/util"
> >
>  <MyObject mapProperty="#props">
>  </MyObject>
> 
>    <util:map id="props">
>       <beans:entry key="sideBar" value="hello" />
>    </util:map>
> </beans:beans>
> 
> On 12/23/06, Paul Austin <mail-lists@revolsys.com> wrote:
> > Ok that works slightly better, with property it works assuming you want
> > the string content. In my real app the content of the map is another
> > type of object.
> >
> > Any ideas on the non-string case?
> >
> > Paul
> >
> > On Sat, 2006-12-23 at 00:07 +0100, Guillaume Nodet wrote:
> >
> > > Try something like that:
> > >
> > > <beans:beans
> > >  xmlns="http://ns.com/app/1.0"
> > >  xmlns:beans="http://www.springframework.org/schema/beans"
> > >  xmlns:util="http://www.springframework.org/schema/util"
> > > >
> > >  <MyObject>
> > >   <mapProperty>
> > >     <property key="sideBar">hello</property>
> > >   </mapProperty>
> > >  </MyObject>
> > > </beans:beans>
> > >
> > > It just occured to me that xbean has its own syntax for maps.
> > >
> > > On 12/22/06, Paul Austin <mail-lists@revolsys.com> wrote:
> > > > I just tried that and also it does not work.
> > > >
> > > > Paul
> > > >
> > > > On Fri, 2006-12-22 at 21:43 +0100, Guillaume Nodet wrote:
> > > >
> > > > > THis is just a guess, but the default namespace is not
> > > > > the spring namespace, so i'm wondering if you should write:
> > > > >
> > > > > <beans:beans
> > > > >  xmlns="http://ns.com/app/1.0"
> > > > >  xmlns:beans="http://www.springframework.org/schema/beans"
> > > > >  xmlns:util="http://www.springframework.org/schema/util"
> > > > > >
> > > > >  <MyObject>
> > > > >    <mapProperty>
> > > > >      <util:map>
> > > > >         <!-- Use the spring namespace for entry -->
> > > > >         <beans:entry key="sideBar" value="hello" />
> > > > >      </util:map>
> > > > >    </mapProperty>
> > > > >  </MyObject>
> > > > > </beans:beans>
> > > > >
> > > > > On 12/22/06, Paul Austin <mail-lists@revolsys.com> wrote:
> > > > > > I am trying to set a map property on a bean using xbean-2.6
and all I
> > > > > > seem to get back is an empty map.
> > > > > >
> > > > > > The bean config file is similar to as shown below.
> > > > > >
> > > > > >
> > > > > > <beans:beans
> > > > > >   xmlns="http://ns.com/app/1.0"
> > > > > >   xmlns:beans="http://www.springframework.org/schema/beans"
> > > > > >   xmlns:util="http://www.springframework.org/schema/util"
> > > > > > >
> > > > > >   <MyObject>
> > > > > >     <mapProperty>
> > > > > >       <util:map>
> > > > > >          <entry key="sideBar" value="hello" />
> > > > > >       </util:map>
> > > > > >     </mapProperty>
> > > > > >   </MyObject>
> > > > > > </beans:beans>
> > > > > >
> > > > > >
> > > > > > If I add a log statement to MyObject.setMapProperty it is called
but the
> > > > > > value is {}. also when I then get the values later it is also
the empty
> > > > > > collection (I was wondering if the map was set first and then
populated
> > > > > > later).
> > > > > >
> > > > > >
> > > > > > class MyObject {
> > > > > >   public void setMapProperty(Map values) {
> > > > > >     log.debug(values);
> > > > > >     this.mapProperty = values;
> > > > > >   }
> > > > > > }
> > > > > >
> > > > > >
> > > > > > Any ideas? Have I got the syntax right?
> > > > > >
> > > > > > Paul
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
> 
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message