use of com.sun.data.provider.RowKey in project Payara by payara.
the class TableHandlers method deleteTableRows.
/**
* <p> This handler deletes the given <code>RowKey</code>s.</p>
*
* @param handlerCtx The HandlerContext.
*/
@Handler(id = "deleteTableRows", input = { @HandlerInput(name = "tableRowGroup", type = TableRowGroup.class, required = true), @HandlerInput(name = "rowKeys", type = RowKey[].class, required = true) })
public static void deleteTableRows(HandlerContext handlerCtx) {
TableRowGroup trg = (TableRowGroup) handlerCtx.getInputValue("tableRowGroup");
RowKey[] keys = (RowKey[]) handlerCtx.getInputValue("rowKeys");
MultipleListDataProvider dp = (MultipleListDataProvider) trg.getSourceData();
for (RowKey key : keys) {
dp.removeRow(key);
}
}
use of com.sun.data.provider.RowKey in project Payara by payara.
the class TableHandlers method getSelectedSingleMapRows.
/**
* <p> This handler looks at the input TableRowGroup, checks which row is selected, and returns a list of the Map.
* <p> Each Map corresponding to one single row of the table.
* <p> This method only works for the table where each row consists of one single map since it only looks at the
* <p> first element that is returned by the getObject() method of <code>MultipleListDataProvider<code>.
*
* <p> Input value: "TableRowGroup" -- Type: <code> com.sun.webui.jsf.component.TableRowGroup</code></p>
* <p> Input value: "selectedRows" -- Type: <code> java.util.List</code></p>
* @param handlerCtx The HandlerContext.
*/
@Handler(id = "getSelectedSingleMapRows", input = { @HandlerInput(name = "TableRowGroup", type = TableRowGroup.class, required = true) }, output = { @HandlerOutput(name = "selectedRows", type = List.class) })
public static void getSelectedSingleMapRows(HandlerContext handlerCtx) {
TableRowGroup trg = (TableRowGroup) handlerCtx.getInputValue("TableRowGroup");
MultipleListDataProvider dp = (MultipleListDataProvider) trg.getSourceData();
List selectedList = new ArrayList();
try {
RowKey[] rowKeys = trg.getSelectedRowKeys();
for (int i = 0; i < rowKeys.length; i++) {
Object[] multiDataRows = (Object[]) dp.getObject(rowKeys[i]);
Object oneMap = multiDataRows[0];
selectedList.add(oneMap);
}
handlerCtx.setOutputValue("selectedRows", selectedList);
} catch (Exception ex) {
GuiUtil.prepareException(handlerCtx, ex);
}
}
Aggregations