From 6a19c73e27d22141ebcc423b0880fee3c8c9bc08 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 17 Apr 2007 14:45:25 +0000 Subject: [PATCH] * Support standard parameters such as prefix, suffix, default for nested parameters (but only convert result to string if actually required) --- src/helma/framework/core/Skin.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/helma/framework/core/Skin.java b/src/helma/framework/core/Skin.java index b9fec322..3991661c 100644 --- a/src/helma/framework/core/Skin.java +++ b/src/helma/framework/core/Skin.java @@ -322,7 +322,7 @@ public final class Skin { private Object processParameter(Object value, RenderContext cx) throws Exception { if (value instanceof Macro) { - return ((Macro) value).invokeAsMacro(cx, null, true); + return ((Macro) value).invokeAsParameter(cx); } else if (value instanceof ProcessedParameter) { return ((ProcessedParameter) value).process(cx.reval); } else { @@ -731,6 +731,26 @@ public final class Skin { return filter(null, cx); } + /** + * Render this macro as nested macro, only converting to string + * if necessary. + */ + Object invokeAsParameter(RenderContext cx) throws Exception { + StandardParams stdParams = standardParams.render(cx); + Object value = invokeAsMacro(cx, stdParams, true); + if (stdParams.prefix != null || stdParams.suffix != null) { + ResponseTrans res = cx.reval.getResponse(); + res.pushBuffer(null); + writeResponse(value, cx.reval, stdParams, true); + return res.popString(); + } else if (stdParams.defaultValue != null && + (value == null || "".equals(value))) { + return stdParams.defaultValue; + } else { + return value; + } + } + /** * Render the macro given a handler object. */