Skip to content

Commit

Permalink
SLICE-128 changes in SliceLookUpTag - backward compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashi Bhushan committed Aug 29, 2016
1 parent 391e3d0 commit c676d8b
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c676d8b

Please sign in to comment.