pp108 : Select

Select

The Select control displays a list of data values (options) as a drop-down list. You can click on the drop-down list to view and choose a value from the control. However, the Select control should contain at least one value for you to be able to use it. You can select only one value from the control.

Select controls need to be pre-filled with values that display to the user. To do so, you can specify the Data set properties in the property sheet of the control.

You can also use enumeration to automatically bind multiple values for a data object using the control. When using enumerated values, you do not need to pre-fill the control using the Data set properties. For information about pre-filling a select control, see Prefilling List and Select Controls.

Select controls can be data-bound or free-form controls. When data-bound, a Select control is bound to a model from which it fetches data. If you do not specify any model, the model of the parent control is associated, by default. You can use a free-form Select control to display any arbitrary data.

You can bind a Select control to a model by setting the Reference property of the associated business object in the control's property sheet. To do so, specify the XPath of the business object's data to be bound. If no model is set for the control, then the control is bound to the model of its parent control, by default.

For information about the Select control, see Dropdown.

Note:
While binding a model, do not use the model used earlier to pre-fill the Select control (using the Data set properties).

Properties, Events, and Methods of the Control

The properties, events, and methods associated with the Select control define its behavior. You can set them either through the control's property sheet or programmatically using the APIs.

Table 1. List of Properties

Design-time property

Runtime property

Description

ID

Sets the string that identifies the control on an XForm. If not specified, a unique ID is automatically generated.

Tab Index

tabIndex

Sets and retrieves the position of the current control in the tabbing order for the current XForm.

Model

Sets the ID of the data model from which the data (specified using the Reference property) is displayed in the control. If model is not specified, it is inherited from the parent control's model.

Reference (xql)

Sets the location or expression for the XPath that contains the data (value) displayed in the control. The XPath refers to the child node or descendants of the immediate parent control's reference.

Enumerated

Denotes whether the Select control can display multi-valued data. Once selected, the Select control's data will be as specified by its Reference property. Also, if selected, there will be no need to pre-fill the control through Data set property. By default, it is unchecked.

Class Name

className

Sets or retrieves the class name applied on the control.

Tooltip

title

Sets the tool tip that appears on a control when the mouse is moved over it. Programmatically, this property is set by specifying the title property of the control.

Data set

Sets the source through which the Select control is filled with options. While using a Select control, options (description and values) are used to choose from. However, this is not required if the Enumerated property is selected.

Task Part

Creates a task part for the control. Selecting the check box, displays the Task Part pane.

Zoom URL

Sets the URL of the Zoom (lookup) page to be opened when the zoom button next to a control is clicked.

Zoom Field

Sets the location or XPath expression that contains the data to be set to the control when the Zoom (lookup) page is closed.

Constraint Validation On Change

Denotes whether validation constraints need to be applied to validate data according to the business logic, when the data associated with a control is changed. This property is available only when a WS-AppServer model is set for a control.

Initialize Value Sets

Sets the value that indicates if the Select control options (Value Sets) need to be retrieved based on the business logic. Possible values are Once, Always, and Never, which denote the frequency of data retrieval. By default, it is set to Never, in which case, the Select control is expected to be filled in by the Dataset. This property is also available if the data model is a WS-AppServer model.

businessObject

Retrieves the root node of the XML data associated with the control; the location of the data is specified by the Reference property.

currentContext

Retrieves the immediate parent of the data that the control represents. This data is the child node of the business object.

data

Retrieves the XML node of the data (value) that the control represents. The location (XPath) of this XML inside the business object is set through the Reference property.

labelXQL

Sets or retrieves the location or expression (XPath) that contains the value to be displayed as the label of the Select control option. This property can also be set at design time using Data set property.

valueXQL

Sets or retrieves the location or expression (XPath) that contains the value of the Select control option. This property can also be set at design time using Data set property.

Inherit

Checking this, control will inherit Feedback Properties from the form. By default this is always checked.

Show Error

Displays the error when the property is checked.

Show Notify

Displays the notification when the property is checked.

Table 2. List of Events

Event

Description

BeforeFill

This event is activated before the Select control is populated with values from the backend. It is activated for each value that is populated.

Change

This event is activated on modifying data in the control, after the Validate event has been fired.

Data Bind

This event is activated before the data is bound to the control.

InFocus

This event is activated when you highlight or focus upon the control.

OutFocus

This event is activated when the control loses its focus.

Validate

This event is activated after the value of the control is changed and the new value is successfully validated against the settings specified in the Formating Options dialog box.

onafterzoom

This event is activated before the zoom page is closed.

onbeforezoom

This event is activated before the zoom page is opened.

Table 3. List of Methods

Method

Description

addListener()

This method registers the control to receive notifications for an event.

addOption (oOptionsObject, bTransaction, iInsertBeforeIndex, bAllowDuplicates)

This method adds an option to the List and Select controls.

addOptions (aValues, bTransaction, iInsertBeforeIndex, bAllowDuplicates)

This method adds multiple options to the List and Select controls.

create()

This method is available for data-bound controls only. It creates an instance of the business object for the control.

disable()

This method disables the control on which it is invoked.

enable()

This method enables the control on which it is invoked.

getAllOptions ()

This method returns a collection of all the options available in the Select and List controls.

getBusinessObject()

This method retrieves data or business object.

getEBIValidate()

This method retrieves the value that indicates whether a validate request was sent to the Cordys WS-AppServer when the data in the control was changed.

getFormatType()

This method retireves the format type that is attached to the control.

getFormattedValue()

This method returns the value that is to be displayed in the control.

getInitializeValueSets()

This method retrieves the value that indicates whether the List or Select control attached to a model, can be automatically initialized using values from the Cordys WS-AppServer.

getLabel()

This method returns the label object associated with the control. It is available for all controls associated with labels.

getMaximumHeight()

This method returns the maximum height of the drop-down list in pixels.

getSelectedOptions ()

This method returns a collection of the selected options in the List and Select controls.

getValue()

This method returns the original value of the control, as available in the database.

hide()

This method hides controls and all associated child controls.

isEnabled()

This method retrieves the value that denotes whether the control is enabled or not.

initialize()

This method pre-fills a Select or List control with data.

rebind(oBusinessObject)

This method is available for all controls bound to a model. This method refreshes the control with data from the business object that is passed as a parameter. If no parameter is passed, the business object of the model's activeTuple node is used and the control is refreshed.

remove()

This method is available only for data-bound controls. It removes the instances marked for deletion.

removeDuplicates (oOptions, bTransaction)

This method removes all duplicates from the Select and List controls.

removeListener()

This method unregisters the control to cease receiving notifications for its events.

removeOption (aIndex, bTransaction)

This method removes an option from the List and Select controls.

removeOptions (aIndexes, bTransaction)

This method removes multiple options from the List and Select controls.

resizeToContent()

This method resizes the drop-down list to fit the largest option.

setEBIValidate()

This method sets the value that indicates whether a validate request must be sent to the Cordys WS-AppServer when the data in the control changes.

setFormatType()

This method sets the format type for the control.

setInitializeValueSets(bValue, bAlways)

This method sets the value that indicates whether the List or Select control attached to a model, can be automatically initialized using values from the Cordys WS-AppServer.

setLabel(sText)

This method sets the text that is passed as a parameter to the label object associated with the control. It is available for all controls associated with a label.

setMaximumHeight(iHeight)

This method sets the maximum allowable height (in pixels) of the drop-down list. The maximum height is 150 pixels, by defaults.

setValue(sValue)

This method sets the value of the control. The sValue parameter denotes the value to be set for the control.

show()

This method makes the control and its children controls visible.


Related tasks

Using WS-AppServer Business Logic in XForms