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