How to use listeners on ADF Table Tree TreeTable

set the property Table. rowselection  to  multiple. when page is runing , use ctrl/shift to select multiple rows.

1.How to get the rows user selected , sample:
mBean

import oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;

import oracle.jbo.Row;

import org.apache.myfaces.trinidad.component.UIXCollection;

import org.apache.myfaces.trinidad.model.RowKeySet;

……

 

    private RichTable table;//binding with table on the page

 

    public String findAllSelectedRows_action() {

        RowKeySet rks = table.getSelectedRowKeys();

        iteratorRKS(rks, table);

        return null;

    }

 

    public void iteratorRKS(RowKeySet rks, UIXCollection collection) {//public method that can be used in iterator tree/table/treeTable

        Iterator it = rks.iterator();

        List<Row> list = new ArrayList<Row>();

        System.out.println("---------mBean--------start print selected rows with all attribtue-----------------");

        while (it.hasNext()) {

            Object rowKey = it.next();

            collection.setRowKey(rowKey);

            JUCtrlHierNodeBinding node = (JUCtrlHierNodeBinding)collection.getRowData();

            String[] strs = node.getAttributeNames();

            for (String str : strs) {

                System.out.print(str + ":" + node.getAttribute(str) + " ");

            }

            System.out.println();

            //put selected rows into AM by a list

            list.add(node.getRow());

        }

        System.out.println("---------mBean--------end print selected rows-----------------");

        Map map = new HashMap();

        map.put("selectList", list);

        BindingContainer bindings = getBindings();

        OperationBinding operationBinding = bindings.getOperationBinding("findAllSelectedRows");

        operationBinding.getParamsMap().put("map", map);

        operationBinding.execute();

}

……

 

AM:

    public Map findAllSelectedRows(Map map) {

        List<Row> selectList = (List<Row>)map.get("selectList");

        System.out.println("-------------------start print in AM-------------------");

        for (Row row : selectList) {

            System.out.println(row.getAttribute(0));

        }

        System.out.println("-------------------end print in AM-------------------");

        return null;

}

 

 

How to use this in tree

mBean:

import oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;

import org.apache.myfaces.trinidad.component.UIXCollection;

import org.apache.myfaces.trinidad.event.SelectionEvent;

import org.apache.myfaces.trinidad.model.RowKeySet;

……

 

private RichTree tree;

 

    public String tree_action2() {

        RowKeySet rks = tree.getSelectedRowKeys();

        iteratorRKS(rks, tree);

        return null;

}

 

    public void iteratorRKS(RowKeySet rks, UIXCollection collection) {

        Iterator it = rks.iterator();

        while (it.hasNext()) {

            Object rowKey = it.next();

            collection.setRowKey(rowKey);

            JUCtrlHierNodeBinding node = (JUCtrlHierNodeBinding)collection.getRowData();

            //start iterator

            String[] strs = node.getAttributeNames();

            for (String str : strs) {

                System.out.print(str + ":" + node.getAttribute(str) + " ");

            }

            System.out.println();

            //

        }

}

……

 


So with treeTable



2.How to listen to the user select, sample 1:

mBean

    public void selectionListener(SelectionEvent selectionEvent) {//binding with table.selectionListener

        RowKeySet rks = selectionEvent.getAddedSet();

        System.out.println("new selected rows:------------");

        iteratorRKS(rks, table);//

        RowKeySet rks2 = selectionEvent.getRemovedSet();

        System.out.println("new deselected rows:------------");

        iteratorRKS(rks2, table);

    }

 

3.How to listen to the user select, sample 2:

mBean

        MySelectEvent mse=new MySelectEvent();

        table.addSelectionListener(mse);

MySelectEvent.java

import org.apache.myfaces.trinidad.event.SelectionEvent;

import org.apache.myfaces.trinidad.event.SelectionListener;

 

public class MySelectEvent implements SelectionListener{

 

    public void processSelection(SelectionEvent selectionEvent) {

      System.out.println("Class3:"+selectionEvent.getSource());

}

 

}

 


Suggetsion:
if you want process your logic immediatly when user select. Use listener(2 3)!other case use 1.




Original(原创)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值