Opcao selecinoar todos para um SelectManyCkeck Box JSF

Pesssoal como faço para fazer um opcão selecionar todos para um SelectManyCkeckBox ? Será que tem como fazer com javascript para selecionar os ckecks ? como fazer?

<h:selectManyCheckbox id="fundo" value="#{ManterSimulacao.fundosSelecionadosCarteira}" layout="pageDirection" >
         <f:selectItems value="#{ManterSimulacao.listarFundosPorFiltro}"/>
</h:selectManyCheckbox>
                           
 <h:selectManyCheckbox value="" >
         <h:outputLabel value="Selecionar Todos"/>
 </h:selectManyCheckbox>

Exemplo básico:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  
    "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:rich="http://richfaces.org/rich"
	template="/templates/template.xhtml"&gt;
	
	&lt;ui:define name="corpo"&gt;
	    &lt;h:form&gt;
	  
	    &lt;h:messages  infoStyle="color: green"/&gt;
	      
	&lt;rich:dataTable align="center" width="60%" id="listFinanciamentos"
			rows="10" onRowMouseOver="this.style.backgroundColor='#CCCCCC'"
			onRowMouseOut="this.style.backgroundColor='#{a4jSkin.rowBackgroundColor}'"
			rowClasses="odd-row,even-row" rendered="true" columnClasses="col"
			var="row"&gt;
			&lt;f:facet name="header"&gt;
				&lt;rich:columnGroup&gt;
					&lt;rich:column style="text-align:center"&gt;
							&lt;h:outputText value="Clientes"/&gt;
						&lt;/rich:column&gt;
						
						

				&lt;/rich:columnGroup&gt;
			&lt;/f:facet&gt;
		&lt;/rich:dataTable&gt;
		
		&lt;a4j:outputPanel ajaxRendered="true"&gt;
		&lt;rich:dataTable align="center" width="60%" id="tabela"
			rows="10" onRowMouseOver="this.style.backgroundColor='#CCCCCC'"
			onRowMouseOut="this.style.backgroundColor='#{a4jSkin.rowBackgroundColor}'"
			rowClasses="odd-row,even-row" rendered="true" columnClasses="col"
			var="row" value="#{clienteController.clientes}"&gt;
			&lt;f:facet name="header"&gt;
				&lt;rich:columnGroup&gt;
					
					&lt;rich:column&gt;
						&lt;h:outputText styleClass="headerText" value="Nome" /&gt;
					&lt;/rich:column&gt;
					
					&lt;rich:column&gt;
						&lt;h:outputText styleClass="headerText" value="Ativo" /&gt;
					&lt;/rich:column&gt;
									
					&lt;rich:column /&gt;

				&lt;/rich:columnGroup&gt;
			&lt;/f:facet&gt;
		
			&lt;rich:column&gt;
				&lt;h:outputText value="#{row.nome}" /&gt;
			&lt;/rich:column&gt;
			
			&lt;rich:column&gt;
				&lt;h:selectBooleanCheckbox value="#{row.ativo}" /&gt;
			&lt;/rich:column&gt;
		
			
		&lt;/rich:dataTable&gt;
		&lt;/a4j:outputPanel&gt;
		&lt;h:commandButton value="Marcar Todos" action="#{clienteController.marcar}"/&gt;
		&lt;h:commandButton value="DesMarcar Todos" action="#{clienteController.desmarcar}"/&gt;
		&lt;/h:form&gt;
		&lt;/ui:define&gt;
		
	&lt;/ui:composition&gt;

MB:

public void marcar(){
		for(Cliente c:clientes){
			c.setAtivo(true);
		}
	}
	
	public void desmarcar(){
		for(Cliente c:clientes){
			c.setAtivo(false);
		}
	}

fiz do lado clientes mesmo , acho que fico melhor utilizando javascript.


 <h:selectManyCheckbox id="fundo" value="#{ManterSimulacao.fundosSelecionadosCarteira}" layout="pageDirection" >
         <f:selectItems value="#{ManterSimulacao.listarFundosPorFiltro}"/>
 </h:selectManyCheckbox>

<h:selectBooleanCheckbox id="btnCkeckSelecionaTodos" onclick="selecionarTodosFundos();"/>
 <h:outputLabel value="Selecionar todos"/>

function selecionarTodosFundos(){
    var marcar = false;
    if(document.getElementById("Form1:j_id25:opcaoPainel:btnCkeckSelecionaTodos").checked){
        marcar = true;
    }
    
    existeFundo = false;
    i = 0;
    do {
        var fundo = document.getElementById("Form1:j_id25:opcaoPainel:fundo:"+i);
        if(fundo != null){
            fundo.checked = marcar;
            existeFundo = true;
        }else{
            existeFundo = false;
        }
        i++;
    }while(existeFundo);
    
}