@HandlerOutput(name="values", type=String.class)
})
public static Object invokeHandler(HandlerContext handlerCtx) {
// First find the HandlerDefinition
String handlerName = (String) handlerCtx.getInputValue("handler");
HandlerDefinition handlerDef = LayoutDefinitionManager.getGlobalHandlerDefinition(handlerName);
if (handlerDef == null) {
throw new IllegalArgumentException("Handler '" + handlerName
+ "' not found!");
}
// Before working with the new Handler, save the old Handler...
com.sun.jsftemplating.layout.descriptors.handler.Handler oldHandler =
handlerCtx.getHandler();
// Create the Handler to invoke...
com.sun.jsftemplating.layout.descriptors.handler.Handler handler =
new com.sun.jsftemplating.layout.descriptors.handler.Handler(handlerDef);
// Now try to get the inputs / outputs
List<String> outputNames = new ArrayList<String>();
String args = (String) handlerCtx.getInputValue("args");
StringTokenizer tok = new StringTokenizer(args, ",");
String nvp, name, value;
Object val = null;
int colon;
while (tok.hasMoreTokens()) {
// Get the NVP...
nvp = tok.nextToken();
colon = nvp.indexOf(':');
if (colon == -1) {
throw new IllegalArgumentException(
"Handler I/O name:value must be separated by a ':'!");
}
name = nvp.substring(0, colon).trim();
value = nvp.substring(colon+1).trim();
// URL decode 'value'...
try {
value = URLDecoder.decode(value, "UTF-8");
} catch (UnsupportedEncodingException ex) {
throw new IllegalArgumentException(
"Unable to decode value, this is not normal!", ex);
}
// See if it is an input...
if (handlerDef.getInputDef(name) != null) {
// It's an input...
if (value.startsWith("{") && value.endsWith("}")) {
Object t = parseString(value.substring(1, (value.length()) - 1));
val = t;
} else {