Thursday, September 7, 2023

How to create a LOV with null value based on a VO

 

Create a properties file 

  1. Right click on a folder in the view controller
  2. Select new and choose "File"
  3. Name the new file and add the .properties extension
  4. In this new file, insert an entry with an id and a value, this entry will be the null selectable value in the LOV

Create a variable

  1. Go to the page definition file and right click the "Variables" in the "Executables" section
  2. Select "Insert inside variableIterator"
  3. Select "Variable"
  4. Set a name and set the type as "java.lang.String"
  5. Create the binding based on the new created variable
  6. Select the add in the "Bindings" section
  7. Select "Attribute Value", set as datasource the "Variables" section
  8. Select the new created variable and press ok

 Create the select one choice based on VO

  1.  In a Jsff fragment, drag and drop an instance of the View Object, select "Single Selection" and then "ADF Select One Choice"
  2. A window will appears where you can select which attribute to display, select "Ok"
  3. Remove the validator and the required attribute
  4. Add the attributes autosubmit="true" and immediate="true"
  5. Replace the default inputValue with the new created variable
 

Adjust settings' LOV

  1. Open the page definition source from the fragment
  2. After the tag <bindings></bindings> add this code and modify the property "PropertiesFile" with the correct path of the previous created file

    <ResourceBundle>
        <PropertiesBundle xmlns="http://xmlns.oracle.com/adfm/resourcebundle" PropertiesFile="path.properties.file"/>
    </ResourceBundle>

  3. Select the LOV in the page definition file and in the Properties tab edit the attribute "ListOperMode" to "setAttribute"
  4. Edit the "NullValueId" attribute. This attribute defines the id that needs to be read in the previous properties file.
  5. Ediit the "NullValueFlag" attribute to "start". This attribute defines the position of the null value in the LOV.

     
To create a LOV with null value avaiable but required input, we need to modify the selectOneChoice adding these attributes:
showRequired="true"
immediate="true"

If no selection was made on the LOV and the user wants to commit, we need to add a warning popup specifing to select a value on the LOV.

This check can be made by checking if the inputValue in the selectOneChoice is not null.

No comments:

Post a Comment