Search in sources :

Example 41 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class CommonHandlers method redirect.

/**
 *	<p> This handler redirects to the given page.</p>
 *
 *	<p> Input value: "page" -- Type: <code>String</code></p>
 *
 *	@param	context	The {@link HandlerContext}.
 */
@Handler(id = "gf.redirect", input = { @HandlerInput(name = "page", type = String.class, required = true) })
public static void redirect(HandlerContext context) {
    String page = (String) context.getInputValue("page");
    FacesContext ctx = context.getFacesContext();
    page = handleBareAttribute(ctx, page);
    // }
    try {
        // FIXME: Should be: ctx.getExternalContext().redirect(page);  See FIXME above.
        ((HttpServletResponse) ctx.getExternalContext().getResponse()).sendRedirect(page);
    } catch (IOException ex) {
        throw new RuntimeException("Unable to redirect to page '" + page + "'!", ex);
    }
    ctx.responseComplete();
}
Also used : FacesContext(javax.faces.context.FacesContext) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) Handler(com.sun.jsftemplating.annotation.Handler)

Example 42 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class CommonHandlers method initClusterSessionAttribute.

/**
 * <p> This handler will be called during initialization when Cluster Support is detected.
 */
@Handler(id = "initClusterSessionAttribute")
public static void initClusterSessionAttribute(HandlerContext handlerCtx) {
    Map sessionMap = handlerCtx.getFacesContext().getExternalContext().getSessionMap();
    // The summary or detail view of deploy tables is stored in session to remember user's previous
    // preference.
    sessionMap.put("appSummaryView", true);
    sessionMap.put("webSummaryView", true);
    sessionMap.put("ejbSummaryView", true);
    sessionMap.put("appclientSummaryView", true);
    sessionMap.put("rarSummaryView", true);
    sessionMap.put("lifecycleSummaryView", true);
    sessionMap.put("adminObjectSummaryView", true);
    sessionMap.put("connectorResSummaryView", true);
    sessionMap.put("customResSummaryView", true);
    sessionMap.put("externalResSummaryView", true);
    sessionMap.put("javaMailSessionSummaryView", true);
    sessionMap.put("jdbcResSummaryView", true);
    sessionMap.put("jmsConnectionSummaryView", true);
    sessionMap.put("jmsDestinationSummaryView", true);
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) Handler(com.sun.jsftemplating.annotation.Handler)

Example 43 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class CommonHandlers method createAttributeMap.

/**
 *	<p> This handler creates a map with the given keys and values </p>
 *
 *  <p> Output value: "map" -- Type: <code>Map</code>/</p>
 *	@param	handlerCtx	The HandlerContext.
 */
@Handler(id = "gf.createAttributeMap", input = { @HandlerInput(name = "keys", type = java.util.List.class), @HandlerInput(name = "values", type = java.util.List.class) }, output = { @HandlerOutput(name = "map", type = java.util.Map.class) })
public static void createAttributeMap(HandlerContext handlerCtx) {
    List<String> keys = (List<String>) handlerCtx.getInputValue("keys");
    List values = (List) handlerCtx.getInputValue("values");
    Map<String, Object> map = new HashMap<String, Object>();
    if (keys != null && values != null) {
        for (int i = 0; i < keys.size(); i++) {
            map.put(keys.get(i), values.get(i));
        }
    }
    handlerCtx.setOutputValue("map", map);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Handler(com.sun.jsftemplating.annotation.Handler)

Example 44 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class CommonHandlers method getFieldLengths.

/**
 * <p>
 * This handler will be called from baseLayout.xhtml to load the maximum
 * field lengths (maximum number of characters that a user can enter in each
 * field).
 */
@Handler(id = "getFieldLengths", input = { @HandlerInput(name = "bundle", type = java.util.ResourceBundle.class, required = true) }, output = { @HandlerOutput(name = "result", type = Map.class) })
public static void getFieldLengths(HandlerContext handlerCtx) {
    ResourceBundle bundle = (ResourceBundle) handlerCtx.getInputValue("bundle");
    Map<String, Integer> result = new HashMap<String, Integer>();
    for (String key : bundle.keySet()) {
        try {
            result.put(key, Integer.decode(bundle.getString(key)));
        } catch (NumberFormatException ex) {
            // Log warning about expecting a number...
            // This should never happen; if it does it's a bug, so no need to localize.
            GuiUtil.getLogger().warning("Field length is expected to be a number, but got ('" + bundle.getString(key) + "') instead for key '" + key + "'.");
        }
    }
    handlerCtx.setOutputValue("result", result);
}
Also used : HashMap(java.util.HashMap) ResourceBundle(java.util.ResourceBundle) Handler(com.sun.jsftemplating.annotation.Handler)

Example 45 with Handler

use of com.sun.jsftemplating.annotation.Handler in project Payara by payara.

the class CommonHandlers method filterAdminObjects.

/**
 *  <p> This handler filters out AdminObjects from a list-jms-resources, only return Connection Factories.
 */
@Handler(id = "filterAdminObjects")
public static List filterAdminObjects(HandlerContext context) {
    List result = new ArrayList();
    FilterTreeEvent event = null;
    try {
        if (context.getEventObject() instanceof FilterTreeEvent) {
            event = FilterTreeEvent.class.cast(context.getEventObject());
        } else {
            return result;
        }
        List<String> jmsResources = event.getChildObjects();
        if (jmsResources == null || jmsResources.size() <= 0) {
            return result;
        }
        List adminObjs = new ArrayList();
        Map responseMap = RestUtil.restRequest(GuiUtil.getSessionValue("REST_URL") + "/resources/admin-object-resource", null, "GET", null, false);
        Map<String, Object> extraPropsMap = (Map<String, Object>) ((Map<String, Object>) responseMap.get("data")).get("extraProperties");
        if (extraPropsMap != null) {
            Map<String, Object> childRes = (Map<String, Object>) extraPropsMap.get("childResources");
            if (childRes != null) {
                adminObjs = new ArrayList(childRes.keySet());
            }
        }
        for (String oneJms : jmsResources) {
            if (!adminObjs.contains(oneJms)) {
                result.add(oneJms);
            }
        }
    } catch (Exception ex) {
        // shouldn't happen.  But weill log in and return empty list.
        GuiUtil.getLogger().warning("Exception in filterAdminObjects()");
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FilterTreeEvent(org.glassfish.admingui.common.tree.FilterTreeEvent) HashMap(java.util.HashMap) Map(java.util.Map) IOException(java.io.IOException) 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