From c676d8b091771230c9613bf5130395cee8bac671 Mon Sep 17 00:00:00 2001 From: Shashi Bhushan Date: Fri, 26 Aug 2016 15:00:12 +0530 Subject: [PATCH] SLICE-128 changes in SliceLookUpTag - backward compatible --- .../slice/api/tag/SliceLookupTag.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/slice-core-api/src/main/java/com/cognifide/slice/api/tag/SliceLookupTag.java b/slice-core-api/src/main/java/com/cognifide/slice/api/tag/SliceLookupTag.java index bdda7cc3..c2af3284 100644 --- a/slice-core-api/src/main/java/com/cognifide/slice/api/tag/SliceLookupTag.java +++ b/slice-core-api/src/main/java/com/cognifide/slice/api/tag/SliceLookupTag.java @@ -33,33 +33,40 @@ public class SliceLookupTag extends SimpleTagSupport { private String appName; // auto-detected when null - private String type; + private String name; + + private Class type; private void clean() { type = null; var = null; appName = null; + name = null; } @Override public void doTag() throws JspException { try { - if (StringUtils.isBlank(var) || (type == null)) { + if (StringUtils.isBlank(var) || (type == null && StringUtils.isEmpty(name))) { throw new JspTagException("Var and Type must be set " + appName); } final PageContext pageContext = (PageContext) getJspContext(); - final Object model = SliceTagUtils.getFromCurrentPath(pageContext, type, appName); + final Object model = StringUtils.isEmpty(name) ? SliceTagUtils.getFromCurrentPath(pageContext, type, appName) : SliceTagUtils.getFromCurrentPath(pageContext, name, appName); pageContext.setAttribute(var, model, PageContext.PAGE_SCOPE); } catch (ClassNotFoundException cause) { - throw new JspTagException("Could not get class for " + type); + throw new JspTagException("Could not get class for " + name + cause.getMessage()); } finally { clean(); } } - public void setType(String type) { - this.type = type; + public void setType(Object type) { + if(type instanceof Class){ + this.type = (Class)type; + }else if(type instanceof String){ + this.name = (String)type; + } } public void setVar(String var) {