There are several posts on internet where it is described how to implement Yes-No (Y-N) type check box using ADF Faces boolean check box component. However, when you want to use Yes-No check box in Query Criteria, there is one additional trick should be applied - I will explain it today.
Download sample application - YesNoSearchBox.zip. In order to run this sample, you need to create additional column in Regions table from HR schema. Make sure you name this column correctly - YES_NO:
For demonstration purpose, I have created static View Object to bring Yes-No values LOV:
Next, I have defined Choice List type LOV for YesNo attribute:
For the same YesNo attribute, make sure that Check Box is specified as Control Type attribute. This will render Check Box in JSF page:
On runtime, YesNo attribute is rendered in Query Criteria and table column:
While it works well, it is not working in Query Criteria. The problem is that Query Criteria block is applying true/false for check box, even it is based on Yes-No LOV component in the Model. Then of course, it is trying to query database with true/false values - and result set is empty, because it expects Y or N.
In order to fix this, make sure you have defined Bind Variable for YesNo attribute in View Criteria:
And we need to create View Object Implementation class, where ADF BC executeQuery() method will be overriden:
This method is accessing View Criteria row and retrieving YesNo criteria attribute value. Retrieved value is compared to true and and Bind Variable value is set to Y. Otherwise, if YesNo criteria attribute value is not equal true, we set Bind Variable value to NULL - this will return all rows:
Querying only those rows with Y: