oracle-adf

Passing parameters with method call


I'm trying to pass a parameter by method cal in a bounded task between two pages: departments and employees, and I'm trying to make employees filter by departmentId. I have a criteria view on employees doing this filter with a Bind Variable vcDeptId and in java:

public void applyViewCriteria(int id)
{
  ViewCriteria vc = getViewCriteria("EmployeesViewFilterByDeptCriteria");
  setvcDepartmentId(id);
  applyViewCriteria(vc);
  executeQuery();
}

On the Departments page I have a table with a button that redirects to the method call:

public void filter()
{
  BindingContext bindingContext = BindingContext.getCurrent();
  DCDataControl dc = bindingContext.findDataControl("AppModuleDataControl");
  AppModuleImpl appM = (AppModuleImpl )dc.getDataProvider();
  Object id =appM.getDepartmentsView1().getCurrentRow().getAttribute("DepartmentId");
  appM.getEmployeesView2().applyViewCriteria(Integer.parseInt(id.toString()));
  System.err.println(id);
}

It turns out that when you go to the employees page, the table doesn't filter, it shows all employees from all departments. I can see in the console that I get the id but I can't do the filter. I don't understand what's missing.. Can someone help me, please??


Solution

  • Actually, you do the filter. However, you do it on a different instance of the view object (VO). When you get the VO from the application module, as you do, you get another fresh instance, not the one used for the table. The table shows data based on an interator binding from the pages pagedef file pageDef.xml the table on the page shows employees via the EmployeesView binding. Ths binding is based on the iterator binding EmployeesViewIterator in the executable section. the view object behind the iterator is the EmployeesView in the data control (or AM). To manipulate the data on the page, you need to get to the vo behind the iterator binding. For this, you can use code like

        BindingContainer lBindingContainer = BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding iterBind= (DCIteratorBinding)lBindingContainer.get("EmployeesViewIterator");
        ViewObject empview = iterBind.getViewObject();
    

    Now you have access to the right VO and can add the view criteria.