A nebo pokud chcete vznikly list sdilet mezi ruznymi bean muzete pouzit:

<bean id="sdilenyList" class="java.util.ArrayList">
  <constructor-arg>
    <list>
        <ref bean="yyyy">
       <ref bean="xxxx">
    </list>
  </construcotr-arg>
</bean>

Btw. doporucuju procist manula ke Springu a zamerit se na sekci kde se pise o 
MAP, SET a LIST (je to hned na jednech z prvnich stran).

> <bean id="b1" class="bean">
>   <property name="generators">
>      <list>
>        <ref bean="yyyy">
>        <ref bean="xxxx">
>      </list>
>   </property>
> </bean>
>
> http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#be
>ans-collection-elements
>
> Od 2.1 resp 2.5 jde vyuzit Autowired anotace
>
> public class bean {
>
>   @Autowired
>   private List<T> generators;
>
> }
>
> List bude naplneny vsemi definovanymi T beanami
>
> http://static.springframework.org/spring/docs/2.1.x/reference/beans.html#be
>ans-autowired-annotation
>
> Vladimír Náprstek napsal(a):
> > Zdravím,
> > mám takový problém - ve springu mám bean, který má jeden atribut typu
> > List a potřebuji prvky nadefinovat v servlet.xml. Asi takto:
> >
> > bean:
> > public class bean {
> >  private List<typ> generators;
> > ...
> >  public setGenerator(typ prvek) {
> >   generators.add(prvek);
> >  }
> > }
> >
> > no a v ...-servlet.xml:
> > <bean id="b1" class="bean">
> >  <property name="generator" ref="xxxxxx" />
> >  <property name="generator" ref="yyyyy" />
> > </bean>
> >
> >
> > vymyšlené hezky, problém je v tom, že toto mi spring nedovolí, druhý
> > pokus o nastavení proměnné generator mi odmítne kvůli multiple property
> > definitions.
> >
> > Je nějaký jiný způsob, jak podobnou věc zařídit?


Odpovedet emailem