In this blog, we will discuss how to set the default value for the select-single LOV. It is a very common yet tricky use case.

The options rendered in select-single are always a pair of value and label – where label is human readable localizable name of the value to use. And in order to provide a default value, you can provide both value and label via "value-item" property, or provide only value via "value" property. But in the latter case, the select-single will ask the data provider associated with the select-single to retrieve the label for given the value, which in turn can lead to an extra REST call when SDP is used and can negatively impact page performance with a REST call which could have been avoided using value-item. Thus, the default value of select-single should be provided via ‘value-item’ property and this can improve page load performance because it will eliminate the need of fetching the selected data from the data provider.

Steps for creating select-single with a default value:

  1. Drag and drop a select-single component on the page designer. In the properties pane for the select-single component, open the ‘Quick Start’ tab and click on ‘Add Options’. Select the data source for the component and then select the label and value for dropdown options from your endpoint structure in the left side. Click Next and Finish on the next page.  

     
  2. Create a page variable ‘selectedEmployee’ of Object type with the below key-data format.
    where, 'key' is where value is put and 'data' is row's data in the same structure as provided by the data provider.
    selectedEmployee variable

     
  3. Assign the initial/default value to the variable ‘selectedEmployee’. 
    default value

     
    Setting default value using value-item property is most useful in editing scenarios like edit record (in form or in editable table) where user must fetch a record to edit. And as part of that fetch, you can also fetch referenced record for the default value of select-single –  both value and label.
    For example – refer the 'Job' column of the Employee table in this VB cookbook recipe which fetches the default value for Job field using value-item property.
     
  4. Now assign the variable ‘selectedEmployee’ to the value-item property of select-single and notice the default value is set. 
    value item

Note: Using Quick Start wizard to assign the data to the component creates SDP, but assigning the default value for the select-single component using value-item attribute is independent of the data provider. You can choose to have SDP or ADP as data provider and yet the process of assigning the default value will be the same.

Link to the documentation: https://www.oracle.com/webfolder/technetwork/jet/jsdocs/oj.ojSelectSingle.html#valueItem