How to use listeners on ADF Table Tree TreeTable
2017-09-26 14:19
375 查看
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:
AM:
How to use this in treemBean:
So with treeTable
2.How to listen to the user select, sample 1:[/b]mBean
3.How to listen to the user select, sample 2:[/b]
mBean
MySelectEvent.java
Suggetsion:if you want process your logic immediatly when user select. Use listener(2 3)!other case use 1.
Original(原创)
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(); } …… |
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 treemBean:
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(); // } } …… |
2.How to listen to the user select, sample 1:[/b]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); } |
mBean
MySelectEvent mse=new MySelectEvent(); table.addSelectionListener(mse); |
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(原创)
相关文章推荐
- How to use search engine on network effectively?
- How to Use Custom TTF Font on iOS
- How to deploy a .Net assmebly for COM use through CAB on Web Page (转)
- How To Use RMAN CONVERT DATABASE on Source Host for Cross Platform Migration
- Note On <Programming Entity Framework 2nd Edition> -01: How to Use LINQPad 4.5
- How to use Objective-C on Window
- How to solve "Address already in use" error on ...
- How to use Ajax on Visualforce page on Salesforce platform
- How to use ActiveSync Remote Display on Windows Embedded CE 6
- How to use SCAN and node listeners with different ports?
- Ubuntu 14.04安装PostgreSQL How To Install and Use PostgreSQL on Ubuntu 14.04
- How to use Samba on Linux?
- How to use HttpWebRequest to post data to another page which is on another server
- How to use Ruijie to contact to the Internet on Ubuntu
- How to use on-screen virtual keyboard on Linux
- How to use Scala on Spark to load data into Hbase/MapRDB -- normal load or bulk load.
- Note On <Programming Entity Framework 2nd Edition> -02: How to Use SqlExpress Profiler 2.0
- How to install and use GCC g++ v4.7 and C++11 on Ubuntu 12.04
- How to Use Google AdSense Ads on Responsive Websites
- How to use OpenID to sign on with Google account