There are numerous occasions where we need to display checkbox whose value isnt just true/false. eg Y/N, Active/Inactive etc
With the use of LOV feature ADF makes our lives easy when creating dropdowns, LOV etc. Infact this same mechanism can be used to create checkboxes when only 2 possible values exists.
The demo of this and several other features can be found in the LookupCodeApp.
Use the following steps:
- Create a simple VO that queries the checkbox values. Lets say YesNoRVO
- Make sure the query fetches the checked value first. i.e If Y is the value to be inserted when checkbox is checked then Y must be the first query result. The simplest way to do this is using order-by clause.
- Open the desired VO and select the attribute that needs to be displayed as a checkbox.
- Create a List of values on the field using YesNoRVO (Checkbox values VO)
- In UI hints tab Leave the "List Type" as it is.
- Make sure that "Display Attribute" is the "value" attribute too. This is necessary in cases where the attribute in main VO is of limited size. eg. DisabledFlag is of type varchar(1)
- Now for the MOST IMPORTANT change from normal LOV: (Drum roll please...) In the main VO attribute's UI Hints, change the "Control Type" to checkbox.
- The best advantage of this approach is that it can be tested in the Application Module tester as well.
- Ofcourse it is re-usable as all checkboxes with Y/N values can use the same YesNoRVO and there is no hard coding necessary.