title: JSF 2.0 Primefaces dynamic table with matrix of dynamic radio buttons
body: <p>I have a p:datatable that iterates through a list of questions in a section of a questionnaire. For each question there can be multiple answers. All questions in a section have the same number of potential answers. Therefore, I'm looking to be able to create a dynamic number of columns based on the number of possible answers and render a selectOneRadio button in each column as part of the same radioGroup so that only one can be selected.</p>
  
  <p>However, when trying to use the custom layout for the radio buttons I am able to select more than one on the same row so they aren't acting as a group. Does anyone know the best way to achieve the desired result?</p>
  
  <pre><code>&lt;ui:composition&gt;
  
  
          &lt;p:dataTable value="#{questions}" var="question"
              styleClass="pro_category_table"&gt;
  
              &lt;f:facet name="header"&gt;
                  &lt;h:outputText value="#{msg[category.categoryType.label]}"&gt;&lt;/h:outputText&gt;
              &lt;/f:facet&gt;
              &lt;p:column headerText="#{msg['long_pro_question_intro1']}"&gt;
                  &lt;h:outputText value="#{msg[question.questionTextKey]}" /&gt;
              &lt;/p:column&gt;
              &lt;p:column&gt;
  
  
              &lt;/p:column&gt;
              &lt;p:columns value="#{category.answerChoicesForSection}" var="categoryHeader" columnIndex="i"&gt;
              &lt;f:facet name="header"&gt;
              #{categoryHeader}
              &lt;/f:facet&gt;
              &lt;p:panel&gt;
              &lt;p:selectOneRadio id="customRadio" value="#{question.selectedAnswers.answers[0]}" layout="custom" 
                      styleClass="pro_select_one_of_many"&gt;
                      &lt;p:ajax update="@(.pro_navigation_button_panel)"/&gt;
                      &lt;f:selectItems var="answer" value="#{question.validAnswers}"
                          itemDescription="#{msg[answer.labelKey]}"
                          itemValue="#{answer.value}" itemLabel=""&gt;&lt;/f:selectItems&gt;
                  &lt;/p:selectOneRadio&gt;
              &lt;p:radioButton for="customRadio" itemIndex="#{i}"&gt;&lt;/p:radioButton&gt;
              &lt;/p:panel&gt;
  
  
              &lt;/p:columns&gt;
  
  
  
          &lt;/p:dataTable&gt;
  
      &lt;/ui:composition&gt;
  </code></pre>