Saturday, October 13, 2018

How to execute lov View Accessor Query?

UseCase:
At each  Employee record, You want to display list of departments, this list of departments is changed according to a parameter changed at run-time.

You click a button and change the parameter value, the LOV must execute its query to fetch the correct data after changing the parameter.

So you have a ViewAccessor  it's query has a parameter ( :bvDeptId ) to filter data,
this parameter is changed during run-time when you click a button you change this parameter but the LOV shows old data, so how to make it's query to be executed:


Departments as list of value (LOV) at EmployeesView

DepartmentsView1 is the ViewAccessor attached to EmployeesView1 ViewObject .
ViewAccessor has a parameter ( bvDeptId ) to filter data,

Solution:
Note: When you create  LOV, you bound an attribute of a ViewObject with a ViewAccessor, This ViewAccessor is a new instance of the ViewObject ( Departments ), this instance is different than instances exists at application module container, this is new instance.

Ways to make the LOV execute it's query:

1- Get the view object which the LOV created on  (EmployeesView1) then retrieve the LOV view accessor  (DepartmentsView1)  then executes it's query:
ApplicationModuleImpl am = ADFUtils.getAppImpl("AppModule");
ViewObject vo =  am.findViewObject("EmployeesView1");
RowSet lov =(RowSet) vo.getCurrentRow().getAttribute("DepartmentsView1"); lov.executeQuery();
2-From the binding container get the LOV attribute and retrieves it's attached view object  then executes it's query:
BindingContainer bindings = getBindingContainer();
//FacesCtrlListBinding
FacesCtrlLOVBinding lov = (FacesCtrlLOVBinding) bindings.get("DepartmentId");
ViewObject departmentVO = lov.getListIterBinding().getViewObject();
departmentVO .executeQuery();
3- You can execute custom method at applicationModuleImpl as described here:
http://come2adf.blogspot.com/2013/05/create-department-while-creating.html

java - fill distinct objects in ArrayList

If you have a list that contains some objects that it is considered as duplication when two or three fields of these objects are equal. How ...