use of com.sun.jsftemplating.annotation.Handler 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);
}
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class TableHandlers method commitTableRowGroup.
/**
* <p> This handler commits the changes to a <code>TableRowGroup</code>'s
* DataProvider.</p>
*
* @param handlerCtx The HandlerContext.
*/
@Handler(id = "commitTableRowGroup", input = { @HandlerInput(name = "tableRowGroup", type = TableRowGroup.class, required = true) })
public static void commitTableRowGroup(HandlerContext handlerCtx) {
TableRowGroup trg = (TableRowGroup) handlerCtx.getInputValue("tableRowGroup");
MultipleListDataProvider dp = (MultipleListDataProvider) trg.getSourceData();
dp.commitChanges();
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class TableHandlers method getAllSingleMapRows.
/**
* <p> This handler takes TableRowGroup as input and returns a List of Map objects.
* <p> The List returned contains Map objects with each Map representing one single row.
* <p> This method only works for tables where each row consists of one single map
*
* <p> Input value: "TableRowGroup" -- Type: <code> com.sun.webui.jsf.component.TableRowGroup</code></p>
* <p> Output value: "Rows" -- Type: <code> java.util.List</code></p>
* @param handlerCtx The HandlerContext.
*/
@Handler(id = "getAllSingleMapRows", input = { @HandlerInput(name = "TableRowGroup", type = TableRowGroup.class, required = true) }, output = { @HandlerOutput(name = "Rows", type = List.class) })
public static void getAllSingleMapRows(HandlerContext handlerCtx) {
TableRowGroup trg = (TableRowGroup) handlerCtx.getInputValue("TableRowGroup");
MultipleListDataProvider dp = (MultipleListDataProvider) trg.getSourceData();
List data = dp.getLists();
try {
handlerCtx.setOutputValue("Rows", data.get(0));
} catch (Exception ex) {
// TODO alert user, log exception
System.out.println("!!!! getAllSingleMapRows() Throws Exception: " + ex.toString());
}
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class WoodstockHandler method populateServerMonitorDropDown.
/**
* <p>
* Returns the list of monitorable server components</p>
*/
@Handler(id = "populateServerMonitorDropDown", input = { @HandlerInput(name = "VSList", type = List.class, required = true), @HandlerInput(name = "GCList", type = List.class, required = true), @HandlerInput(name = "NLList", type = List.class, required = true), @HandlerInput(name = "ThreadSystemList", type = List.class, required = true) }, output = { @HandlerOutput(name = "MonitorList", type = Option[].class) })
public void populateServerMonitorDropDown(HandlerContext handlerCtx) {
List vsList = (List) handlerCtx.getInputValue("VSList");
List threadList = (List) handlerCtx.getInputValue("ThreadSystemList");
List gcList = (List) handlerCtx.getInputValue("GCList");
List nlList = (List) handlerCtx.getInputValue("NLList");
ArrayList menuList = new ArrayList();
menuList.add(new Option("", ""));
// Menu for Virtual Servers
OptionGroup vsMenuOptions = getMenuOptions(vsList, "virtual-server", "", false);
if (vsMenuOptions != null) {
menuList.add(vsMenuOptions);
}
// Menu for Listeners
OptionGroup nlMenuOptions = getMenuOptions(nlList, "http-listener", "", false);
if (nlMenuOptions != null) {
menuList.add(nlMenuOptions);
}
// Menu for Garbage Collectors
OptionGroup gcMenuOptions = getMenuOptions(gcList, "garbage-collector", "", false);
if (gcMenuOptions != null) {
menuList.add(gcMenuOptions);
}
// Menu for Thread System
OptionGroup tsMenuOptions = getMenuOptions(threadList, "thread-system", "", false);
if (tsMenuOptions != null) {
menuList.add(tsMenuOptions);
}
// Add Menu Options.
jumpMenuOptions = (Option[]) menuList.toArray(new Option[menuList.size()]);
// Arrays.sort(jumpMenuOptions);
handlerCtx.setOutputValue("MonitorList", jumpMenuOptions);
}
use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.
the class WoodstockHandler method populateResourceMonitorDropDown.
/**
* <p>
* Returns the list of monitorable resource components</p>
*/
@Handler(id = "populateResourceMonitorDropDown", input = { @HandlerInput(name = "ResourceList", type = List.class, required = true) }, output = { @HandlerOutput(name = "MonitorList", type = Option[].class), @HandlerOutput(name = "FirstItem", type = String.class) })
public void populateResourceMonitorDropDown(HandlerContext handlerCtx) {
List rList = (List) handlerCtx.getInputValue("ResourceList");
ArrayList menuList = new ArrayList();
// Menu for Resources
ArrayList resList = new ArrayList();
String firstItem = null;
if (rList != null) {
ListIterator rl = rList.listIterator();
while (rl.hasNext()) {
String name = (String) rl.next();
resList.add(new Option(name, name));
if (firstItem == null) {
firstItem = name;
}
}
}
Option[] groupedOptions1 = (Option[]) resList.toArray(new Option[resList.size()]);
OptionGroup jumpGroup1 = new OptionGroup();
jumpGroup1.setLabel("resources");
jumpGroup1.setOptions(groupedOptions1);
menuList.add(jumpGroup1);
// Add Menu Options.
jumpMenuOptions = (Option[]) menuList.toArray(new Option[menuList.size()]);
handlerCtx.setOutputValue("MonitorList", jumpMenuOptions);
handlerCtx.setOutputValue("FirstItem", firstItem);
}
Aggregations