use of com.sun.jsftemplating.annotation.Handler 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.jsftemplating.annotation.Handler in project Payara by payara.
the class TableHandlers method convertListToArrayList.
/**
* <p> This handler converts the table list to arraylist.</p>
*
* @param handlerCtx The HandlerContext.
*/
@Handler(id = "convertListToArrayList", input = { @HandlerInput(name = "TableList", type = List.class, required = true), @HandlerInput(name = "Name", type = String.class) }, output = { @HandlerOutput(name = "NameList", type = ArrayList.class) })
public static void convertListToArrayList(HandlerContext handlerCtx) {
List tableList = (List) handlerCtx.getInputValue("TableList");
String name = (String) handlerCtx.getInputValue("Name");
if (GuiUtil.isEmpty(name))
name = "name";
if (tableList != null) {
ListIterator li = tableList.listIterator();
ArrayList names = new ArrayList();
while (li.hasNext()) {
Map props = (Map) li.next();
String val = (String) props.get(name);
if (!GuiUtil.isEmpty(val))
names.add(val);
}
handlerCtx.setOutputValue("NameList", names);
}
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class TableHandlers method convertRowsToProperties.
/**
* <p> This handler converts the table List to a Property map.
*
* @param handlerCtx The HandlerContext.
*/
@Handler(id = "convertRowsToProperties", input = { @HandlerInput(name = "NewList", type = List.class, required = true) }, output = { @HandlerOutput(name = "AddProps", type = Map.class) })
public static void convertRowsToProperties(HandlerContext handlerCtx) {
List newList = (List) handlerCtx.getInputValue("NewList");
ListIterator li = newList.listIterator();
Map addProps = new HashMap<String, String>();
while (li.hasNext()) {
Map props = (Map) li.next();
String name = (String) props.get("name");
if (name != null && (!name.trim().equals(""))) {
if (addProps.containsKey(name)) {
// duplicate property name, give error
GuiUtil.handleError(handlerCtx, GuiUtil.getMessage("msg.duplicatePropTableKey", new Object[] { name }));
return;
}
addProps.put(name, (String) props.get("value"));
}
}
handlerCtx.setOutputValue("AddProps", addProps);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class TableHandlers method getSelectedTableRowKeys.
/**
* <p> This handler returns the selected row keys.</p>
*
* @param handlerCtx The HandlerContext.
*/
@Handler(id = "getSelectedTableRowKeys", input = { @HandlerInput(name = "tableRowGroup", type = TableRowGroup.class, required = true) }, output = { @HandlerOutput(name = "rowKeys", type = RowKey[].class) })
public static void getSelectedTableRowKeys(HandlerContext handlerCtx) {
TableRowGroup trg = (TableRowGroup) handlerCtx.getInputValue("tableRowGroup");
handlerCtx.setOutputValue("rowKeys", trg.getSelectedRowKeys());
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class TableHandlers method getAddRemoveProps.
/**
* <p> This handler returns the properties to be removed and added.</p>
*
* @param handlerCtx The HandlerContext.
*/
@Handler(id = "getAddRemoveProps", input = { @HandlerInput(name = "NewList", type = List.class, required = true), @HandlerInput(name = "OldList", type = Map.class, required = true), @HandlerInput(name = "NameList", type = ArrayList.class, required = true) }, output = { @HandlerOutput(name = "AddProps", type = Map.class), @HandlerOutput(name = "RemoveProps", type = ArrayList.class) })
public static void getAddRemoveProps(HandlerContext handlerCtx) {
List newList = (List) handlerCtx.getInputValue("NewList");
ArrayList names = (ArrayList) handlerCtx.getInputValue("NameList");
Map<String, String> oldList = (Map) handlerCtx.getInputValue("OldList");
ListIterator li = newList.listIterator();
ArrayList removeProps = new ArrayList();
Iterator iter = oldList.keySet().iterator();
Map addProps = new HashMap<String, String>();
while (li.hasNext()) {
Map props = (Map) li.next();
if (!oldList.containsKey(props.get("name"))) {
String name = (String) props.get("name");
if (name != null && (!name.trim().equals(""))) {
addProps.put((String) props.get("name"), (String) props.get("value"));
}
}
if (oldList.containsKey(props.get("name"))) {
String oldvalue = (String) oldList.get(props.get("name"));
String newvalue = (String) props.get("value");
if (!oldvalue.equals(newvalue)) {
removeProps.add((String) props.get("name"));
String name = (String) props.get("name");
if (name != null && (!name.trim().equals(""))) {
addProps.put((String) props.get("name"), (String) props.get("value"));
}
}
}
}
if (iter != null) {
while (iter.hasNext()) {
Object key = iter.next();
if (!names.contains(key)) {
removeProps.add((String) key);
}
}
}
handlerCtx.setOutputValue("AddProps", addProps);
handlerCtx.setOutputValue("RemoveProps", removeProps);
}
Aggregations