Designer 10.15 | webMethods CAF and OpenUI Development | Understanding the Client-side Model | CAF.Checkbox.Model
 
CAF.Checkbox.Model
Check boxes are used as part of a larger check box group, which are modeled by the CAF.Select.Model. However, the individual check box control, UISelectBoolean is modeled by the CAF.Checkbox.Model, which extends the CAF.Input.Model. With the check box model, getValue() returns the string true if the check box is checked, and an empty string, if the check box is not checked. You can take advantage of JavaScript's notion of truthy and falsy, where true equals boolean true, and "" equals boolean false.
For example, if a Checkbox control has an ID of myCheckboxId, and next to a TextInput control has an ID of myTextInputId, you could disable and clear the text input. You want to disable and clear the text input if the check box is toggled unchecked, and enable the text input if the check box is toggled checked. You could apply the following value change listener to accomplish this:
CAF.model('#{activePageBean.clientIds['myCheckboxId']}').addValueChangeListener
(function(id, oldValue, newValue) {
var checked = newValue;
var input CAF.model('#{activePageBean.clientIds['myTextInputId']}=');
input.setDisabled(!checked); if (!checked) input.setValue(""); });
You can also use the getLabel() and setLabel(label) methods to dynamically get and set the check box's label.
For more information about CAF controls, see the webMethods CAF Tag Library Reference, as described in Finding Information about CAF Controls.
Related Topics