Applying View Criteria from Application Module
Often we need to define and invoke View Object filtering. In ADF 11g we can do this by adding WHERE clause to View Object SQL statement or by defining View Criteria and invoking it later. I prefer second approach, why I should play with SQL statement, if ADF 11g can generate it for me. Okej, when there is View Criteria, it should be invoked. There are different approaches to do this - from declarative to programmatic. Today I will describe my preferred approach, I'm not saying you should use it as well.
Download sample application - AppModuleQuery.zip. This sample implements View Criteria to filter employees based on their department:
Here is the first trick - I have defined Bind Variable setter method to pass variable value and exposed this method through client interface:
This means I will call it later from Controller layer to pass correct Bind Variable value. Its important to say, you should do ExecuteQuery when new Bind Variable is passed, this will ensure it will be correctly reinitialized:
Now most interesting part starts, you can declare View Criteria to be executed automatically, each time when View Object is accessed. You can do this in Application Module - select View Object from Data Model section and click Edit:
Select View Criteria you want to trigger automatically - it will be invoked each time when View Object will be accessed:
Model part is done, now its time to look into Contoller. As you remember, Bind Variable setter method was exposed through client interface, it is present in Data Control:
Drag and drop it into ADF Bounded Task Flow, it is needed to set correct Bind Variable value. In my case it is defined as Default Activity:
On runtime, JobId value is passed as Input Parameter for ADF Bounded Task Flow, where it is used for Bind Variable setter method parameter:
ADF Bounded Task Flow is opened, Bind Variable value is set and View Criteria applied automatically:

Download sample application - AppModuleQuery.zip. This sample implements View Criteria to filter employees based on their department:
Here is the first trick - I have defined Bind Variable setter method to pass variable value and exposed this method through client interface:
This means I will call it later from Controller layer to pass correct Bind Variable value. Its important to say, you should do ExecuteQuery when new Bind Variable is passed, this will ensure it will be correctly reinitialized:
Now most interesting part starts, you can declare View Criteria to be executed automatically, each time when View Object is accessed. You can do this in Application Module - select View Object from Data Model section and click Edit:
Select View Criteria you want to trigger automatically - it will be invoked each time when View Object will be accessed:
Model part is done, now its time to look into Contoller. As you remember, Bind Variable setter method was exposed through client interface, it is present in Data Control:
Drag and drop it into ADF Bounded Task Flow, it is needed to set correct Bind Variable value. In my case it is defined as Default Activity:
On runtime, JobId value is passed as Input Parameter for ADF Bounded Task Flow, where it is used for Bind Variable setter method parameter:
ADF Bounded Task Flow is opened, Bind Variable value is set and View Criteria applied automatically:





































































RSS
Email