Skip to main content

Overriding <af:query> display at run time

Sometime back I posted similar post on the above topic - Customizing the af:query component display by overriding CriteriaItemAttributeHints

Its time for me to revisit the same topic with slightly different use case :)
The use case requirement was to override the ViewCrtieria hints of a base view object from a child view object. Well, its easy. You can hook your code by overriding ViewObjectImpl::getCriteriaItemAttributeHints(ViewCriteriaItem vci), and optionally return your own AttributeHints implementation. In the following code sample, I'm demonstrating this by changing some properties of a ViewCriteriaItem for specific items.

  * By default return null. Subclasses may override to return  
  * custom AttributeHints implementation for the given criteria item.  
 public AttributeHints getCriteriaItemAttributeHints(ViewCriteriaItem vci) {  
   if (vci != null && vci.getViewCriteria().getName().equals("EmployeesViewCriteria")) {  
     if (vci.getAttributeDef().getName().equals("FirstName")) {  
     } else if (vci.getAttributeDef().getName().equals("DepartmentId")) {  
       vci.setProperty(ViewCriteriaItem.RENDERED_MODE, ViewCriteriaItem.CRITERIA_RENDERED_MODE_NEVER);  
   return super.getCriteriaItemAttributeHints(vci);  

Before winding up today's post, let me teach you one more useful tip on the same context. An interesting enhancement available with release is the ability specify 'Display Width' for each view criteria item while defining a view criteria. This property decides the width of the UI control (displayed inside the query component) at run time. Please note that in previous releases the af:query component was using display width from the view object's attribute definition (by default) to render controls.


You can download the sample workspace from here.
[Runs with Oracle JDeveloper (11g R2) + HR Schema]

A glance at the implementation

This sample uses 2 view object
1. A base view object - EmployeesView
2. A child view object extended from EmployeesView - EmpDeptView. Child view object inherits 'EmployeesViewCriteria' defined on base view object.

The EmpDeptViewImpl overrides certain properties of 'EmployeesViewCriteria' from the base view object by using getCriteriaItemAttributeHints(...) method. Take a look at the below shown scree shot to understand this example better. The screen shot displays two query components one from EmployeesView and the other from EmpDeptView. Though both query components are derived from same ViewCriteria defined on the base view object (EmployeesView), the second component displays slightly modified version by hiding the DepartmentId field and marking the FirstName as 'optional'. This is achieved by the altering ViewCriteriaItem instance in the getCriteriaItemAttributeHints(...) method.

Learn More ...

There are a lot more points like this. If  you are curious to learn the internals of the ADF Business Components and ADF Binding Layer,  the following book is for you - Oracle ADF Real World Developer’s Guide.
More details about this book can be found in this post-


Anonymous said…
Hi Jobinesh,
Based on your post of Dynamic LOV, I am trying to create a radio group in a dynamic form component. I created a ListBinding and setting the AttributeHints of the column as

"AttrDef[itr].setProperty(AttributeHints.ATTRIBUTE_CTL_TYPE, AttributeHints.CTLTYPE_RADIOGRP);"

But still I am not getting the radio group displayed on the page. Am I missing something?

I am trying to create the following components dynamically in a dynamic form and was not able to





Can you please point me in some direction?

Thanks in advance
Anonymous said…
you have mentioned a new feature since (Display width of item in query component). I'm using currently the newest, but this feature doesn't work. All the items are stretched automaticly (according to database length i think). It doesn't work neither when i set up the Display width in Attributes/UI Hints. Do you have any experience with this? thanks

Same error of anonymous:

"You have mentioned a new feature since (Display width of item in query component). I'm using currently the newest, but this feature doesn't work. All the items are stretched automatically (according to database length i think). It doesn't work neither when i set up the Display width in Attributes/UI Hints. Do you have any experience with this?"

Have any idea of how to solve it?

Jobinesh said…
Well, I had a look at it. Look like the way this property has been defined in VO xml has been changed between builds and it's not being migrated when you open an application in release of JDev. A work around is given here:
1. Open the application in
2. Open the VO. Then open the VC in the VC editor. Got to UI Hints tab, select Criteria item and set the Display Width
3. After step2, Got to source tab of VO, and select the VC and then manually remove the previously defined(which is added added when you set UI hints for VC Item using ver) SchemaBasedProperties and its child tags for the VC Item .

If you have many such instances and above step is not a feasible option for you, please file a Bug through Oracle Service Request.

Popular posts from this blog

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…