Designing and Implementing Composite Applications : webMethods CAF and OpenCAF Development Help : Understanding the Client-side Model : CAF.Select.Model
CAF.Select.Model
UISelectOne and UISelectMany controls extend the CAF.Input.Model with the CAF.Select.Model. The value of a select-one control such as a dropdown and radio-button group, is the string value of the selected item, or an empty string, if no item is selected. The value of a select-many control such as a list box or a checkbox group, is the array of selected item values, or an empty array if no items are selected.
Individual select items are modeled by CAF.Select.Item.Model, which has value, label, description, disabled, style (inline CSS style), styleClass (CSS class name), and icon URL properties. Setting these properties does not affect the control directly. Call the set(x,item) method on the select control model with the updated select item in order to update the control. The first argument (x) of this method is the zero-based index of the item, or the string value of the item.
Symmetric to the set(x,item) method, the get(x) method retrieves the CAF.Select.Item.Model at either the specified zero-based index or with the specified string value. You can get the full list of CAF.Select.Item.Model items in the control using the list() method. The selected() method returns an array of the selected CAF.Select.Item.Model items.
You can add items to the control using the add(x,item) method. The first argument to this method (x) is the index string value, or the CAF.Select.Item.Model of the existing item. Use the remove(x) method to delete Items. The first argument to this method (x) is the index, string value or CAF.Select.Item.Model of the item to remove.
The following example appends and selects an Item from a dropdown. The first argument specified for the CAF.Select.Item.Model's constructor is the value of the new item. The second argument is its label.
Note:  
When reading the Javadoc for CAF JavaScript objects, the constructor for the object is the method named initialize() which is the convention defined by the Prototype library.
dropdown.add(new CAF.Select.Item.Model("value-ten", "Item Ten"));
dropdown.setSelected("value-ten", true);
You can select Items using the setSelected(x,selected) method. The first argument to this method (x) is the index, string value, or CAF.Select.Item.Model of the item to select. Test the selection state of an item using the isSelected(x) method. The first argument to this method (x) is e the index, string value, or CAF.Select.Item.Modelof the item to test.
The CAF.Select.Model model supports value change listeners that are notified every time the control's selection state changes. The CAF.Select.Model provides for selection change listeners. Selection change listeners are notified only when a change occurs to selection state of the specific item for which the selection change listeners are associated. The listener receives three arguments:
*The control ID
*The specific item value to listen for changes
*The new selection state, true for selected, false for not selected
The addSelectionChangeListener(fn,value) method enables registering the selection change listeners. The first argument to this method (fn) specifies the listener method, and the second argument (value) specifies the value of the item for which to listen. The following example adds a selection change listener to the myDropdownId control. If the value-on item is selected, the listener shows myPanelOneId; if its not selected, it hides myPanelOneId:
CAF.model('#{activePageBean.clientIds
['myDropdownId']}').addSelectionChangeListener(function
(id, value, selected) {
var panel = CAF.model('#{activePageBean.clientIds['myPanelOneId']}');
if (selected)
panel.show();
else
panel.hide();
}, "value-one");
For more information about CAF controls, see the webMethods CAF Tag Library Reference, as described in Finding Information about CAF Controls.
Copyright © 2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback