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; }
|
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
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()); }
} |