Binding data to a select widget

This section provides an example of how to bind data to a select widget.

Procedure

To define data structure:

  1. If you get data from context.
    1. You need to specify data structure as following, an IndexedCollection data which includes a KeyedCollection Data, then there are two fields, field labelselect is for lable of select widget, field valueselect is for value of select widget.
      Note: Every IndexedCollection data must have at least one kColl data type as a root data container.
    2. Then you need to specify the submitted data for the select widget. For example, it can be selectData.selectName.

  2. If you get data from list files. You need to create a new javascript file in your project directory /WebContent/listFiles, for example: normal.js, the content is like:
    {
    	'A label' : 'VAL1',
    	'Another label here'	: 'VAL2',
    	'Label 0001' : 'Value0001',
    	'Label 0002' : 'Value0002',
    	'Label 0003' : 'Value0003',
    	'Label 0004' : 'Value0004',
    	'Label 0005' : 'Value0005'
    }
  3. You need to specify properties for select widget. If you want to get data from list files, you need to specify value for urlForList, if you want to get data from context data, you need to specify value for dataNameForList , labelField and valueField. You need to specify dataName for either of the two modes, which is the submitted value for select widget.

Results

Data is bound to the select widget.