title: Creating property to a ref bean, Spring
body: <p>I have searched in this site a lot of spring.. but i'm really new to this..
  so here is my question:</p>
  
  <p>I have 3 main classes i'm gonna put it like this..</p>
  
  <pre><code> public class User
   {
      private String name;
      private ArrayList&lt;Car&gt; cars;
  
      public ArrayList&lt;Car&gt; getCars() 
      {
         return cars;
      }
  
      public void setCars(ArrayList&lt;Car&gt; cars) 
      {
         this.cars= cars;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
         this.name = name;
      }
   }
  
   public class Car
   {
      private String type;
      private ArrayList&lt;Wheel&gt; wheels;
  
      public ArrayList&lt;Wheel&gt; getWheels() 
      {
         return wheels;
      }
  
      public void setWheels(ArrayList&lt;Wheel&gt; wheels) 
      {
         this.wheels= wheels;
      }
  
      public String getType() {
          return type;
      }
  
      public void setType(String type) {
         this.type= type;
      }
   }
  
   public class Wheel
   {
      private String name;        
  
      public String getName() {
          return name;
      }
  
      public void setType(String name) {
         this.name= name;
      }
   }
  </code></pre>
  
  <p>That's the Java code.. this is just an example. So i have 3 classes, as u see one is the user that can have one or many cars, then is the car that can have one or many wheels..</p>
  
  <p>In my Spring.xml i want to do something like this..</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"&gt;
  
      &lt;bean id="car1" class="Car"&gt;
          &lt;property name="type" value="motorcycle"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="wheel1" class="Wheel"&gt;
          &lt;property name="name" value="one"/&gt;
      &lt;/bean&gt;
      &lt;bean id="wheel2" class="Wheel"&gt;
          &lt;property name="name" value="two"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="user1" class="User"&gt;
          &lt;property name="name" value="Me"/&gt;
          &lt;property name="cars"&gt;
              &lt;list value-type="Car"&gt;
                  &lt;ref bean="car1"&gt;
                    &lt;property name="wheels"&gt;
                       &lt;ref bean="wheel1"&gt;
                       &lt;ref bean="wheel2"&gt;
                    &lt;/property"&gt;
                  &lt;/ref&gt;
              &lt;/list&gt; 
          &lt;/property&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>If u see this spring.. i want to create the user instance and the cars and wheels by spring-code.. but it won't let me do this.. cause i can't create a ref bean with a property children.. so i can't add wheels to my ref bean car.. how can i do this? or this can't be done this way, maybe is another solution to this.. dunno.. Thanks in advance..</p>
  
  <p>Sorry for my bad english.</p>