int index = 0; for (HtmlCheckBox checkBox : getCheckBoxes()) { checkBox.setId(checkBox.getName() + "/" + index++);
for (HtmlCheckBox checkBox : getCheckBoxes()) {
    public HtmlTag getOwnTag(PageContext context) {        for (HtmlCheckBox checkBox : getCheckBoxes()) {            checkBox.setName(getName());                        if (getTargetSlot() != null) {                checkBox.setTargetSlot(getTargetSlot());            }        }        for (HtmlHiddenField hiddenField : getHiddenFields()) {            hiddenField.setName(getName());                        if (getTargetSlot() != null) {                hiddenField.setTargetSlot(getTargetSlot());            }        }                if (isSelectAllShown()) {            StringBuilder selectAllScript = new StringBuilder();            boolean allChecked = true;                        String allCheckBoxId = getName() + "/all";                        int index = 0;            for (HtmlCheckBox checkBox : getCheckBoxes()) {                checkBox.setId(checkBox.getName() + "/" + index++);                                if (! checkBox.isChecked()) {                    allChecked = false;                }                                selectAllScript.append("document.getElementById('" + checkBox.getId() + "').checked = this.checked; ");                                String eachScript = "if (! this.checked) document.getElementById('" + allCheckBoxId + "').checked = false;";                checkBox.setOnClick(eachScript);                checkBox.setOnDblClick(eachScript);            }                        HtmlCheckBox checkAllBox = addOption(new HtmlText(RenderUtils.getResourceString("renderers.checkboxlist.selectAll")), 0);            checkAllBox.setId(allCheckBoxId);            checkAllBox.setChecked(allChecked);            checkAllBox.setOnClick(selectAllScript.toString());            checkAllBox.setOnDblClick(selectAllScript.toString());        }                for (int i = 0; i < this.list.getItems().size(); i++) {            HtmlListItem item = this.list.getItems().get(i);            HtmlInlineContainer container = new HtmlInlineContainer();                        container.addChild(getCheckBoxes().get(i));            container.addChild(item.getBody());                        item.setBody(container);        }                if (getHiddenFields().size() > 0) {            HtmlContainer container = new HtmlInlineContainer();                        container.addChild(list);            for (HtmlHiddenField hiddenField : getHiddenFields()) {                container.addChild(hiddenField);            }                        return container.getOwnTag(context);        }        else {            return this.list.getOwnTag(context);        }    }