4 Replies Latest reply on Dec 3, 2009 10:11 AM by Suresh M

    Question about seam:component

    Chuanbao Lu Newbie

      I want to use javascript to select/deselect all the certificate by click the SelectAll checkBox on the header.


      Does anybody know how to reference a component in a dataTable?


      {rich:component('certSelected')} is wrong.


      <rich:dataTable id="certificateList"
                var="_cert"
                value="#{certificateManager.quote.certificates}"
                rendered="#{not empty certificateManager.quote.certificates}">
        <h:column>
         <f:facet name="header">
              <h:selectBooleanCheckbox id="selectAll" title="Select all/none" 
                 onclick="#{rich:component('certSelected')}.checked 
                        = #{rich:component('selectAll').checked}"/>
         </f:facet>
         <h:selectBooleanCheckbox id="certSelected" value="#{_cert.selected}">
        </h:column>
      </rich:dataTable>
      



        • 1. Re: Question about seam:component
          Ingo Jobling Master

          Sounds like a job for <rich:jQuery/>

          • 2. Re: Question about seam:component
            Chuanbao Lu Newbie

            Thank you Ingo. I coded like this. It works good.


            <h:column>
               <f:facet name="header">
                  <h:selectBooleanCheckbox id="selectAll" title="Select all/none"/>
               </f:facet>
               <h:selectBooleanCheckbox id="certSelected" value="#{_cert.selected}"/>
            </h:column>
            
            <rich:jQuery selector="#selectAll" query="click(function() 
                 {selectCerts(null, jQuery(this).attr('checked'));})"/>
            <rich:jQuery selector="input[@id*=certSelected]" name="selectCerts" 
                 timing="onJScall" query="attr('checked',param)"/> 
            

            • 3. Re: Question about seam:component
              Suresh M Newbie
              I used your code for Select all/unselect. But, it’s thrown JavaScript error. Can you plz explain the second line of <rich:jQuery> and also what is the ‘param’ value?. What should I give instead of param?  Anyone have idea plz tell me.
              • 4. Re: Question about seam:component
                Suresh M Newbie
                I used Jquery like this,It's working fine

                <script type="text/javascript">
                         jQuery(document).ready(function(){
                              jQuery('input[id*=selectAll]').click(function(){
                                   var status = this.checked;
                                   jQuery('input[id*=selectRow]').each(function(){
                                        this.checked = status
                                   });
                              });
                         });
                    </script>

                <rich:column  style="text-align:center" >
                                    <f:facet name="header">
                                         <h:selectBooleanCheckbox id="selectAll"/>
                                    </f:facet>
                                    <h:selectBooleanCheckbox value="#{countryList.selectedCountry[countryDAO.code]}" id="selectRow"/>
                               </rich:column>