Search in sources :

Example 1 with RowKey

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);
    }
}
Also used : RowKey(com.sun.data.provider.RowKey) MultipleListDataProvider(com.sun.jsftemplating.component.dataprovider.MultipleListDataProvider) TableRowGroup(com.sun.webui.jsf.component.TableRowGroup) Handler(com.sun.jsftemplating.annotation.Handler)

Example 2 with RowKey

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);
    }
}
Also used : RowKey(com.sun.data.provider.RowKey) MultipleListDataProvider(com.sun.jsftemplating.component.dataprovider.MultipleListDataProvider) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TableRowGroup(com.sun.webui.jsf.component.TableRowGroup) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

RowKey (com.sun.data.provider.RowKey)2 Handler (com.sun.jsftemplating.annotation.Handler)2 MultipleListDataProvider (com.sun.jsftemplating.component.dataprovider.MultipleListDataProvider)2 TableRowGroup (com.sun.webui.jsf.component.TableRowGroup)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1