title: How to create a linked list using JSF2
body: <p>What I want to do is not a simple linked list, but the design is very similar to it, so I asked the question like this just to make things simpler to explain.</p>
  
  <p>The application I´m working on has a certain domain object that can be created by a user in a particular page. This newly created instance may or may not have a reference to another instance of the same class. Such another instance will be created in the very moment the first one is being created, which means, I´m not linked my under creation object to a previous existing one, but to one that is being created at the very moment it's being linked to.</p>
  
  <p>The domain class is something like this:</p>
  
  <pre><code>class MyItem {
    private String name;
    private MyItem next;
  
    // getters and setters
  }
  </code></pre>
  
  <p>The user wants a page where it's possible to set a name to a new instance of <code>MyItem</code> and eventually click a button to add the next item. In response to this click, a new line must be shown right below the first instance with a field to fill in the name of the next item and another button to eventually add a third item. The process can continue until we have a big number of instances, all connected to each other from the first to the last item. This is the so called linked list of the question.</p>
  
  <p>When the user clicks the save button, many instances should be persisted at once.</p>
  
  <p>How should I approach this use case in a JSF 2 application?</p>
  
  <p>Thanks in advance!</p>