Wednesday, September 14, 2016

Setting table current row using custom selection listener

For implementing custom selection listener on table, update default selection listener by creating SelectionEvent bean reference 

New custom table selection listener will be 

selectionListener="#{pageFlowScope.SampleBean.customSelectionListener}"

Snippet code to set current row on row selection , for this sample First name is printed on row selection 

public void customSelectionListener(SelectionEvent selectionEvent) {
    RichTable _table = (RichTable)selectionEvent.getSource();
    CollectionModel model = (CollectionModel)_table.getValue();
    JUCtrlHierBinding _binding = (JUCtrlHierBinding)model.getWrappedData();
    DCIteratorBinding iteratorBinding = _binding.getDCIteratorBinding();
    Object _selectedRowData = _table.getSelectedRowData();
    JUCtrlHierNodeBinding node = (JUCtrlHierNodeBinding)_selectedRowData;
    Key rwKey = node.getRowKey();
    iteratorBinding.setCurrentRowWithKey(rwKey.toStringFormat(true));

    DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding itorBinding = bindings.findIteratorBinding("EmployeesVO1Iterator");
    System.out.println(itorBinding.getCurrentRow().getAttribute("FirstName"));
}

Output





No comments:

Post a Comment