2

This is the code of a list of checkboxes:

<div class="span8">
    <h:panelGrid id="columnGrid" width="450">
        <rich:orderingList id="columnlist" value="#{EquipReportBean.settings}" listWidth="400" listHeight="250" var="item">
            <s:convertEntity />
            <rich:column>
                <h:selectBooleanCheckbox value="#{item.show_column}" id="showColumn"/>
            </rich:column>
            <rich:column>
                <h:outputText value="#{item.column_id.name}" id="columnName"></h:outputText>
                </rich:column> 
        </rich:orderingList>
    </h:panelGrid> 
</div>

I ve already found a lot of about JavaScript in the internet about checking/uncheckin all. But the problem here it's that I don't have all the checkboxes IDs to check through code. How can I do the function to check or uncheck all of them using another checkbox. Thank you!

Alexandre Lavoie
  • 8,711
  • 3
  • 31
  • 72

2 Answers2

2

I've already done that with RichFaces and jQuery years ago, that should do the trick in your case :

<rich:column>
    <f:facet name="header">
       <input type="checkbox" onclick="jQuery(#{rich:element('columnlist')}).find('input[type=checkbox]').attr('checked',this.checked);" />
    </f:facet>

    <h:selectBooleanCheckbox value="#{item.show_column}" id="showColumn"/>
</rich:column>

More info :

Alexandre Lavoie
  • 8,711
  • 3
  • 31
  • 72
2

Add the same styleClass to your checkboxes ( Richfaces style classes redefinition ):

styleClass="checkboxToCheckClass"

Then through javascript (jquery here) :

jQuery('.checkboxToCheckClass').attr('checked', true);

This link can help you : Using jquery to get all checked checkboxes with a certain class name

Community
  • 1
  • 1
kmas
  • 6,401
  • 13
  • 40
  • 62