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.


2 comments:

This doesn't seem to work for me. Maybe something has changed in 11.1.1.2.0?

I get the following behaviour:
- if the value is null, the checkbox is checked
- if the value is not null, the checbox is unchecked.

February 15, 2010 at 2:35:00 AM PST  

The above example is in 11.1.1.2
What are the values you are trying to achieve? What is your query in LOV VO?

February 16, 2010 at 7:12:00 AM PST  

Newer Post Older Post Home