Search in sources :

Example 96 with Handler

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);
    }
}
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)

Example 97 with Handler

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

Example 98 with Handler

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

Example 99 with Handler

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);
}
Also used : OptionGroup(com.sun.webui.jsf.model.OptionGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Option(com.sun.webui.jsf.model.Option) Handler(com.sun.jsftemplating.annotation.Handler)

Example 100 with Handler

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);
}
Also used : OptionGroup(com.sun.webui.jsf.model.OptionGroup) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Option(com.sun.webui.jsf.model.Option) ListIterator(java.util.ListIterator) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

Handler (com.sun.jsftemplating.annotation.Handler)167 ArrayList (java.util.ArrayList)85 Map (java.util.Map)85 List (java.util.List)82 HashMap (java.util.HashMap)81 TreeMap (java.util.TreeMap)14 IOException (java.io.IOException)12 Date (java.util.Date)9 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)8 LayoutViewHandler (com.sun.jsftemplating.layout.LayoutViewHandler)8 Image (com.sun.pkg.client.Image)8 ListIterator (java.util.ListIterator)8 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 FacesContext (javax.faces.context.FacesContext)7 AttributeList (javax.management.AttributeList)7 RestResponse (org.glassfish.admingui.common.util.RestResponse)7 URL (java.net.URL)6 IntegrationPoint (org.glassfish.admingui.connector.IntegrationPoint)6 MultipleListDataProvider (com.sun.jsftemplating.component.dataprovider.MultipleListDataProvider)5 TableRowGroup (com.sun.webui.jsf.component.TableRowGroup)5