title: Primefaces: selecting rows from nested DataTables
body: <p>I'm using Primefaces 3.4 and Groovy.  I created objects <code>Part</code> and <code>Attachment</code>:</p>
  
  <pre><code>class Part {
      Attachment selectedAttachment
      List&lt;Attachment&gt; attachments = []
  
      AttachmentDataModel getAttachmentModel() {
          return new AttachmentDataModel(attachments)
      }
  }
  
  class Attachment {
      String fileName
      String fileType
      String description
  }  
  </code></pre>
  
  <p>My view has nested DataTables like so:</p>
  
  <pre><code>&lt;p:dataTable value="#{mybean.parts}" var="part" rendered="#{mybean.attachmentsFound}"&gt;
      &lt;p:column&gt;
          &lt;p:dataTable 
              var="attachment"
              selectionMode="single"
              value="#{part.attachmentModel}"
              selection="#{part.selectedAttachment}"
              &gt;
              &lt;p:column headerText="File Name"&gt;
                  #{attachment.fileName}
              &lt;/p:column&gt;
              &lt;p:column headerText="File Description" style="width: 200px"&gt;
                  #{attachment.description}
              &lt;/p:column&gt;
              &lt;p:column headerText="File Type" style="width: 20px"&gt;
                  #{attachment.fileType}
              &lt;/p:column&gt;
          &lt;/p:dataTable&gt;
      &lt;/p:column&gt;
  &lt;/p:dataTable&gt;
  </code></pre>
  
  <p>I want to be able to select one attachment per part.</p>
  
  <p><strong>Problem:</strong> Only the <em>first</em> part's <code>selectedAttachment</code> gets set to the <em>last</em> selected attachment!  </p>
  
  <p><strong>Question:</strong> How can I enable each part instance to save its selected attachment?  Thanks for your time.</p>
  
  <p><em>Note: If I debug my AttachmentDataModel, I see <code>getRowData</code> hit for as many selections as I make.</em></p>