Trying to create a checkbox to check all items in a treenode. I'm kind of new to JSF so I'm pretty stumped as how to implement this on a tree instead of a table. This is the current code:
<rich:panel style="width:400px;">
<h:selectBooleanCheckbox id="vehicleAll" onclick="selectAllModel(this.checked);">
</h:selectBooleanCheckbox>
<h:outputText value=" ALL"/>
<rich:tree id="vehicleTree" switchType="client"
value="#{applicationScope.demoModelGrpList}" var="node" ajaxKeys="#{null}"
binding="#{demoRptController.vehicleUiTree}"
nodeSelectListener="#{demoRptController.selectionListener}"
changeExpandListener="#{demoRptController.expansionListener}"
ajaxSubmitSelection="true">
<rich:treeNode id="modelNode" ajaxSingle="true"
icon="/images/pixel_node.gif" iconLeaf="/images/pixel_node.gif">
<h:selectBooleanCheckbox id="cbxNode" value="#{node.selected}" style="position:relative; float:left; left:-22px;" class="vcBx">
</h:selectBooleanCheckbox>
<h:outputText value="#{node.name}" style="position:relative; float:left; left:-16px;"/>
</rich:treeNode>
</rich:tree>
</rich:panel>
Script is:
<script type="text/javascript">
<![CDATA[
function selectAllModel(checks) {
alert("calling select all");
var array = document.getElementsByTagName("input");
for(var i = 0; i < array.length; i++)
{
if(array[i].type == "checkbox")
{
if(array[i].className == "vcBx")
{
array[i].checked = checks;
}
}
}
}
]]>
</script>
I placed the alert there for testing purposes; it's not even being called. I'm pretty sure I have my syntax correct so this has me scratching my head.