ADF Query supports out of the box between search operator. This operator is applied for single VO attribute, ADF renders two field (from and to) on UI to enter search range. We may have different use case - to display on UI only one query field and in the background to search by two different attributes (minimum and maximum range value). I will describe how to implement such use case, sample application is available for download as usual.
Here is use case for sample application, you can download - SearchInRangeApp.zip:
Jobs table contains two attributes - Minimum and Maximum Salary. We would like to provide to the user only one field - Salary. User will type value, execute search and get results where entered Salary value is in between Minimum and Maximum Salary.
ADF UI looks like this - Salary field from ADF Query and results table with both Minimum and Maximum salary values:
When ADF Query is executed, it generates query for both MIN_SALARY and MAX_SALARY:
How to achieve this? There is a trick you can apply for View Criteria definition. View Criteria contains both - MinSalary and MaxSalary attributes. Pay attention - both attributes point to the same Bind Variable, this is needed because we pass only one single value from ADF Query for both attributes:
Both attributes are included into View Criteria, but we need to display only one - set second attribute (MaxSalary for example) to be Never rendered:
MinSalary attribute label is renamed to Salary - to show it in ADF Query. We need to display MinSalary label in results table, for this purpose - duplicate attribute MinSalaryResults with label Minimum Salary is defined:
Of course you could use same attribute MinSalary in both ADF Query and for results table - however, then would need to define label for MinSalary appearing in results table inside ViewController. I prefer to keep ADF BC elements labels inside Model project.
Here is use case for sample application, you can download - SearchInRangeApp.zip:
Jobs table contains two attributes - Minimum and Maximum Salary. We would like to provide to the user only one field - Salary. User will type value, execute search and get results where entered Salary value is in between Minimum and Maximum Salary.
ADF UI looks like this - Salary field from ADF Query and results table with both Minimum and Maximum salary values:
When ADF Query is executed, it generates query for both MIN_SALARY and MAX_SALARY:
How to achieve this? There is a trick you can apply for View Criteria definition. View Criteria contains both - MinSalary and MaxSalary attributes. Pay attention - both attributes point to the same Bind Variable, this is needed because we pass only one single value from ADF Query for both attributes:
Both attributes are included into View Criteria, but we need to display only one - set second attribute (MaxSalary for example) to be Never rendered:
MinSalary attribute label is renamed to Salary - to show it in ADF Query. We need to display MinSalary label in results table, for this purpose - duplicate attribute MinSalaryResults with label Minimum Salary is defined:
Of course you could use same attribute MinSalary in both ADF Query and for results table - however, then would need to define label for MinSalary appearing in results table inside ViewController. I prefer to keep ADF BC elements labels inside Model project.
Actually its not a missing feature but an ugly written section in the security guide. The following three sentences - copied from the same doc - explain how it really works
ReplyDelete1) "ADF Security does not perform permission checking for ADF methods; you must enable permission checking in your application. Based on a resource permission you have granted to the user for the ADF method, the user interface will either enable or disable the command component."
2) "You create a resource permission to map the invoke permission action to the execute operation." This means that you press the plus icon for ADF method in the security editor to create a new Resource permission. This resource permission is what you then create instance of and grant to users. Doing so then gives sense to (3)
3) "You use the Expression Builder dialog that you display for the UI component display property to define an EL expression that checks the user's access rights to the method. When you run the application, the component will appear either enabled or disabled based on the outcome of the EL expression ADF method permission check."
The problem is that "ADF Method" neglects the fact that it is a resource permission. When the doc author talks about selecting an ADF method then he doesn't mean to select a method in a PageDef file but a Resource Permission defined as an ADF Method (confusing, I know).
I'll file a bug to get this explained