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

    Question about seam:component

    lcbdl888

      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
          joblini

          Sounds like a job for <rich:jQuery/>

          • 2. Re: Question about seam:component
            lcbdl888

            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
              msureshmd
              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
                msureshmd
                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>