0 Replies Latest reply on Oct 7, 2009 3:27 PM by sai burgula

    JSF Seam Radio Button display

    sai burgula Novice
      I have a list of elements returned from a backing bean. I am trying to display the list using radio buttons. I tried the following way(using h:selectOneRadio):

      <rich:dataTable id="courseTable" value="#{courseSearch.courseResultList}" var="var"
                              rows="20" sortMode="single">
                                                                                              <rich:column>
                                                                                                      <f:facet name="header">
                                                                                                              <h:outputText value="Select" />
                                                                                                      </f:facet>
                                                                                                      <h:selectOneRadio onclick="radioButton(this);"
                                                                                                              valueChangeListener="#{courseSearch.selectedCrsRow}">
                                                                                                              <f:selectItem itemValue="null"/>

              </h:selectOneRadio>
                                                                                              </rich:column>
                                                                                              <rich:column>
                                                                                                      <f:facet name="header">
                   <h:outputText value="Semester" />
              </f:facet>
                                                                                                      <h:outputText value="#{var.id.semester}" />
                                                                                              </rich:column>
                                                                                              <rich:column sortBy="#{var.id.courseNo}">
                                                                                                      <f:facet name="header">
                 <h:outputText value="Course #" />
              </f:facet>
                                                                                                      <h:outputText value="#{var.id.courseNo}" />
                                                                                              </rich:column>
                                                                                              <rich:column sortBy="#{var.id.section}">
                                                                                                      <f:facet name="header">
                <h:outputText value="Section" />
              </f:facet>
                                                                                                      <h:outputText value="#{var.id.section}" />
                                                                                              </rich:column>
                                                                                              <rich:column>
                                                                                                      <f:facet name="header">
                 <h:outputText value="Title" />
              </f:facet>
                                                                                                      <h:outputText value="#{var.courseTitle}" />
                                                                                              </rich:column>
      </rich:dataTable>



      The "radioButton(this)" calls the following javascript function.

      <script type="text/javascript">
                  function radioButton(radio) {
                  var id = radio.name.substring(radio.name.lastIndexOf(':'));
                  var el = radio.form.elements;
                  for (var i = 0; i < el.length; i++) {
                      if (el[i].name.substring(el[i].name.lastIndexOf(':')) == id) {
                          el[i].checked = false;
                      }
                  }
                  radio.checked = true;
              }



      The following code is in my Backing Bean:

                        public CourseOffering selectedCrsRow(ValueChangeEvent event) {
                      selectedCourse = (CourseOffering) courseTable.getRowData();
                      return selectedCourse;
                                   }
                         public CourseOffering getSelectedCrsRow(){
                       return this.selectedCourse;
               }


      But I am not able to accomplish a successful implementation of a radio button. This is enabling me to select multiple buttons.

      Please let me know how to display radio buttons on a list being returned from a backing bean. Any example of that sort will help me a lot.

      thanks
      Sai

      =

      =

      #