6 Replies Latest reply on May 14, 2009 3:06 PM by tony.herstell1

    Table and checkboxes

    tony.herstell1

      I have a rich:table.
      In a column is a checkbox.

      I want to check some checkboxes and then when I press the swaptimes buttons do the time swap in on the server of the checked rows.

      The call does happen to the server for

      eventsEntryController.swapTimesOfCompetitors(eachClass)

      but the checkboxes have not been set in the "model".




      <a4j:form>
       <rich:dataTable id="#{eachClass.id}table" columnClasses="table_entry text_important" width="100%"
       value="#{eachClass.competitorDetails}" var="eachEntry" rows="0"
       onRowMouseOver="this.style.backgroundColor='#F8F8F8'"
       rendered="#{eachClass.competitorDetails.size > 0}"
       onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
       <f:facet name="header">
       <h:outputText value="Competitors (#{eachClass.competitorDetails.size})"/>
       </f:facet>
      ...
      
      
      <rich:column rendered="#{identity.loggedIn and s:hasRole('ADMINISTRATOR')}">
       <f:facet name="header">
       <h:outputText value="Swap Candidate" />
       </f:facet>
       <h:selectBooleanCheckbox value="#{eachEntry.swapCandidate}"/>
      </rich:column>
      
      ...
      
      
      </rich:dataTable>
       <center>
       <a4j:commandButton styleClass="general_form_button"
       rendered="#{identity.loggedIn and s:hasRole('ADMINISTRATOR')}"
       action="#{eventsEntryController.swapTimesOfCompetitors(eachClass)}"
       value="#{messages.general_button_swap_times}" type="submit">
       </a4j:commandButton>
       </center>
      </a4j:form>



      Entity:
      @SuppressWarnings("serial")
      @Entity
      @Name("competitorDetails")
      public class CompetitorDetails implements Serializable {
      ...
       @Transient
       private boolean swapCandidate;
      ...
       public boolean isSwapCandidate() {
       return swapCandidate;
       }
      
       public void setSwapCandidate(boolean swapCandidate) {
       this.swapCandidate = swapCandidate;
       }
      ...



      How do I get my checkboxes updated in the model?

        • 1. Re: Table and checkboxes

          Hi tony.herstell, I've worked on a similar problem and have found a solution for myself. My page-code looks similar to yours - with three differences:

          This are the differences:
          1. ID at the element

          <h:selectBooleanCheckbox id="YOUR_ID" value="#{eachEntry.swapCandidate}"/>
          


          2. Usage of h:commandButton instead of a4j:commandButton

          3. I don't use seam now (but will do this in a later stage ;-})

          Other related points could be:
          conditional rendering problem?
          ajax-stuff with submit all values, but processing only specific one?

          Hope this helps you, or give you some input....


          regards
          rschoeler

          • 2. Re: Table and checkboxes
            tony.herstell1

            Thanks rschoeler,

            I tried all these to no avail.

            Thanks anyhow.

            • 3. Re: Table and checkboxes
              tony.herstell1

              i have noticed that for an id for the table i get

              <td><form id="j_id157:0:j_id184" name="j_id157:0:j_id184" method="post" action="/site/pages/events/showEvent.seam">id9table<table class="dr-table rich-table " id="j_id157:0:j_id184:idtable"


              This is from this:

              <h:outputText value="id#{eachClass.id}table" />
              <rich:dataTable id="id#{eachClass.id}table"


              SO why is the id for the table NOT
              d="j_id157:0:j_id184:id9table


              Note the 9!

              • 4. Re: Table and checkboxes
                tony.herstell1

                Looking through the code I see

                {'affected':['id9table'] ,'similarityGroupingId':'j_id157:0:j_id184:idtable:2:j_id210','parameters':
                


                • 5. Re: Table and checkboxes
                  tony.herstell1

                  #####

                  THIS IS 100% tied to having two+ tables on 1 page (the last table on the page works).

                  This bug is already raised as a JIRA

                  <a4j:repeat value="#{event.classes}" var="eachClass">
                  
                  ...
                  <a4j:form>
                   <h:outputText value="id#{eachClass.id}table" />
                  ...
                  
                  
                  </a4j:repeat>


                  #####

                  • 6. Re: Table and checkboxes
                    tony.herstell1