Skip to main content

Part1 - Hiding Unwanted Operators in Advanced mode of af:query Component

Oracle ADF helps you to build af:query component declaratively by dropping view criteria defined in a view object on to a page. While building view criteria you can create custom operators or remove built-in operators (displayed in advanced mode of af:query component) for each view criteria item by adding <CompOper/> to the view object XML file. Note that you may need to do it manually, there is no editor support for the same. This concept is explained in developers guide under the topic - How to Create Custom Operators or Remove Standard Operators.

The attributes used in <CompOper/> as as follows:

  • Name: Specify an id for the operation.
  • ToDo: Set to 1 to add this custom operator. Set to -1 to remove an operator.
  • OperDescStrCode: Specify the id used in the message bundle to map to the description string.
  • Oper: Set to a value that will be used programmatically to denote this operation in the SQL statement. 
  • MinCardinality: If there is an input range, set this property to the minimum value for the range. For example, if the range is months in a year, this value should be set to 1. If there is no range, set it to 0.
  • MaxCardinality: If there is an input range, set this property to the maximum value for the range. For example, if the range is months in a year, this value should be set to 12. If there is no range, set it to 0.
  • TransientExpression: Set the expression to perform the custom operator function. 
In the following example operators BETWEEN and NOTBETWEEN are removed for 'Email' ViewCriteriaItem in the advanced mode of af:query component.

  <ViewCriteria  
     Name="EmployeesViewCriteria"  
     ViewObjectName="model.EmployeesView"  
     Conjunction="AND">  
     <Properties>  
       <CustomProperties>  
         <Property  
           Name="displayOperators"  
           Value="InAdvancedMode"/>  
         <Property  
           Name="autoExecute"  
           Value="false"/>  
         <Property  
           Name="allowConjunctionOverride"  
           Value="true"/>  
         <Property  
           Name="showInList"  
           Value="true"/>  
         <Property  
           Name="mode"  
           Value="Basic"/>  
       </CustomProperties>  
     </Properties>  
     <ViewCriteriaRow  
       Name="EmployeesViewCriteria_row_0"  
       UpperColumns="1">  
       <ViewCriteriaItem  
         Name="Email"  
         ViewAttribute="Email"  
         Operator="="  
         Conjunction="AND"  
         Required="Optional">  
         <CompOper  
           Name="Name"  
           Oper="BETWEEN"  
           ToDo="-1"  
           MinCardinality="0"  
           MaxCardinality="0"/>  
         <CompOper  
           Name="Name"  
           Oper="NOTBETWEEN"  
           ToDo="-1"  
           MinCardinality="0"  
           MaxCardinality="0"/>  
       </ViewCriteriaItem>  
       <ViewCriteriaItem  
         Name="EmployeesViewCriteria_EmployeesViewCriteria_row_0_DepartmentId"  
         ViewAttribute="DepartmentId"  
         Operator="="  
         Conjunction="AND"  
         Required="Optional"/>  
     </ViewCriteriaRow>  
 </ViewCriteria>  



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- http://jobinesh.blogspot.in/2012/07/pre-order-your-copy-of-oracle-adf-real.html

Comments

Siva said…
Hi Jobinesh,

As usual, a very useful post.
AndyNal said…
How can I do this in runtime?
Anonymous said…
nice post. Thanks
Anonymous said…
Hi Jobinesh,
Is there any way to hide Advanced button for a view criteria in VO.xml?

Thanks

Popular posts from this blog

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…