title: JSF 2.0 ArrayList Property of Managed Bean
body: <p>I am using JSF 2.0 Mojarra.</p>
  
  <p>I need to create a Managed Bean that contains a property of type List.  I need to initialize this list with some values in the Faces-Config.xml.  My question is, what does the structure of my Class need to look like to accomplish this.</p>
  
  <p>For example,</p>
  
  <pre><code>public class Items{
       private List&lt;Item&gt; itemList = new ArrayList&lt;&gt;();
  
       public List&lt;Item&gt; getItemList(){
       return itemList;
  }
  
  public void setItemList (List&lt;Item&gt; itemList){
       this.itemList = itemList;
  }
  
  //Methods needed for adding and removing type Item elements to/from itemList.
  //What is the convention, so that JSF can initialize these values?
  
  public class Item{
       //This is a nested class
       private String itemProperty1;
       private String itemProperty2;
  
       //Getters and Setters for itemProperty1 and itemProperty2 have been omitted
       //for brevity.
     }
  }
  </code></pre>
  
  <p>Further, once I have my Class set up properly.  What is the correct structure of the Faces-Config.xml.  For example, should I do it like this:</p>
  
  <pre><code> &lt;managed-bean&gt;
     &lt;managed-bean-name&gt;items&lt;/managed-bean-name&gt;
     &lt;managed-bean-class&gt;com.bricks.model.Items&lt;/managed-bean-class&gt;
     &lt;managed-bean-scope&gt;Application&lt;/managed-bean-scope&gt;
     &lt;managed-property&gt;
       &lt;property-name&gt;itemList&lt;/property-name&gt;
       &lt;value-class&gt;com.brick.model.Items.Item&lt;/value-class&gt;
       &lt;list-entries&gt;
         &lt;value&gt;item1&lt;/value&gt;
         &lt;value&gt;item2&lt;/value&gt;
       &lt;/list-entries&gt;
    &lt;/managed-property&gt;
  &lt;/managed-bean&gt;
  
  &lt;managed-bean&gt;
    &lt;managed-bean-name&gt;item1&lt;/managed-bean-name&gt;
    &lt;managed-bean-class&gt;com.bricks.model.Item&lt;/managed-bean-class&gt;
    &lt;managed-bean-scope&gt;None&lt;/managed-bean-scope&gt;
    &lt;managed-property&gt;
      &lt;property-name&gt;itemProperty1&lt;/property-name&gt;
      &lt;value&gt;value1&lt;/value&gt;
    &lt;/managed-property&gt;
    &lt;managed-property&gt;
      &lt;property-name&gt;itemProperty2&lt;/property-name&gt;
      &lt;value&gt;value2&lt;/value&gt;
    &lt;/managed-property&gt;
  &lt;/managed-bean&gt;
  
   &lt;!--Repeat for item2 --&gt;
  </code></pre>
  
  <p>Thanks in advance for the help.</p>