Search in sources :

Example 91 with Handler

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);
    }
}
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 92 with Handler

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);
    }
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ListIterator(java.util.ListIterator) HashMap(java.util.HashMap) Map(java.util.Map) Handler(com.sun.jsftemplating.annotation.Handler)

Example 93 with Handler

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ListIterator(java.util.ListIterator) HashMap(java.util.HashMap) Map(java.util.Map) Handler(com.sun.jsftemplating.annotation.Handler)

Example 94 with Handler

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

Example 95 with Handler

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) ArrayList(java.util.ArrayList) List(java.util.List) ListIterator(java.util.ListIterator) HashMap(java.util.HashMap) Map(java.util.Map) 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