This discussion is archived
1 Reply Latest reply: Sep 7, 2013 5:32 AM by oladslw RSS

how to dynamically display the data from a table base on row selection of another table in ADF

Nilesh Kumar Singh Newbie
Currently Being Moderated

Hi ,

I have a requirement in ADF. I need to change the data of a table  based on row selection of another Table . Both the table have a Parent Child relationship between them. They have a common attribute say department_id.

                                                                                     For this I created bind variable in view object of employees table and wrote a where clause in the sql query using that bind variable. Then I created method for selection listener of department Table in java bean.

My method is following

    public void onrowselection(SelectionEvent selectionEvent) {

        RichTable richTable = (RichTable)selectionEvent.getSource();

                        CollectionModel tableModel = (CollectionModel)richTable.getValue();

                        JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();

                        Object selectedRowData = richTable.getSelectedRowData();

                        JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;

 

 

                oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");

                Number pallet = newVal.bigDecimalValue();

                System.out.println("Selected values " + pallet);

      

                       

        BindingContext bindingctx = BindingContext.getCurrent();

                     

                      BindingContainer bindings = bindingctx.getCurrentBindingsEntry();

                      DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;

              DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file

                      ViewObject vo =dciter.getViewObject();

                      vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value

                      vo.executeQuery();

;

            

      

              

    }

 

It is printing the selected value of department id from department table in the log. But it is not able to pass the value to employees view. It is showing the following error in the log

"Definition DepartmentId of type Variable is not found in EmployeesView1."

I will be very thankful if someone helps me to solve this errror or is there any other way to achieve the same requirement.

Thanks

Nilesh

  • 1. Re: how to dynamically display the data from a table base on row selection of another table in ADF
    oladslw Newbie
    Currently Being Moderated

    Note quite sure why you simply wont create a viewlink for the viewobject the tables are based on..

     

    The viewlink attribute will be based on the departmentId and it's a simple master detail relationship which automatically uses ppr.

     

    However, if both tables are on the same page; using your hack about;

     

    On the underlying viewobject, define a viewcriteria e.g. "listById" and set your bind variable here.

     

    I would bind table two to a RichTable component:

     

    RichTable t2;

     

    public void onrowselection(SelectionEvent selectionEvent) {

            RichTable richTable = (RichTable)selectionEvent.getSource();

                            CollectionModel tableModel = (CollectionModel)richTable.getValue();

                            JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();

                            Object selectedRowData = richTable.getSelectedRowData();

                            JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;

     

     

                    oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");

                    Number pallet = newVal.bigDecimalValue();

                    System.out.println("Selected values " + pallet);

         

                          

                   refreshTable2(pallet);

            BindingContext bindingctx = BindingContext.getCurrent();

                        

                          BindingContainer bindings = bindingctx.getCurrentBindingsEntry();

                          DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;

                  DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file

                          ViewObject vo =dciter.getViewObject();

                          vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value

                          vo.executeQuery();

       }

     

    private void refreshTable2(Number pallet){

    RichTable x=getT2();

    CollectionModel cm=(CollectionModel)x.getValue();

    JUCtrlHierBinding jcb=(JUCtrlHierBinding)cm.getWrappedData();

    BindingContainer bindings = bindingctx.getCurrentBindingsEntry();

    DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;

    DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(jcb.getName()+"Iterator");

    ViewObject vo =dciter.getViewObject();

    ViewCriteriaManager vcm=vo.getViewCriteriaManager();

    ViewCriteria vc=vcm.getViewCriteria("listById");

    vo.applyViewCriteria(vc);

    vo.setNamedWhereClauseParam("DepartmentId",pallet);

    vo.executeQuery();

    AdfFacesContext.getCurrentInstance().addPartialTarget(getT2());

    }

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points