return resolveVariable(null, null, name);
}
//-- VariableResolverX --//
public Object resolveVariable(XelContext ctx, Object base, Object onm) {
if (base != null) {
final Page page = ((ExecutionCtrl)_exec).getCurrentPage();
return page != null ? page.getXelVariable(ctx, base, onm, true): null;
}
if (onm == null)
return null;
final String name = onm.toString();
if (name == null || name.length() == 0) //just in case
return null;
//Note: we have to access keyword frist (rather than component's ns)
//since 1) BeanShell interpreter will store back variables
//and page.getZScriptVariable will return the old value
//2) ZK 5, getAttributeOrFellow doesn't look for variable resolvers and implicit objects
if ("arg".equals(name))
return _exec.getArg();
if ("componentScope".equals(name)) {
if (_self instanceof Component)
return ((Component)_self).getAttributes(Component.COMPONENT_SCOPE);
return Collections.EMPTY_MAP;
}
if ("desktopScope".equals(name))
return _exec.getDesktop().getAttributes();
if ("desktop".equals(name))
return _exec.getDesktop();
if ("execution".equals(name))
return _exec;
if ("pageScope".equals(name)) {
if (_self instanceof Component)
return ((Component)_self).getAttributes(Component.PAGE_SCOPE);
if (_self instanceof Page)
return ((Page)_self).getAttributes();
final Page page = ((ExecutionCtrl)_exec).getCurrentPage();
return page != null ? page.getAttributes(): Collections.EMPTY_MAP;
}
if ("page".equals(name)) {
if (_self instanceof Component)
return getPage((Component)_self);
if (_self instanceof Page)
return (Page)_self;
return ((ExecutionCtrl)_exec).getCurrentPage();
}
if ("requestScope".equals(name))
return _exec.getAttributes();
if ("self".equals(name))
return _self;
if ("sessionScope".equals(name))
return _exec.getDesktop().getSession().getAttributes();
if ("session".equals(name))
return _exec.getDesktop().getSession();
if ("spaceOwner".equals(name)) {
if (_self instanceof Component)
return ((Component)_self).getSpaceOwner();
if (_self instanceof Page)
return (Page)_self;
return null;
}
if ("spaceScope".equals(name)) {
if (_self instanceof Component)
return ((Component)_self).getAttributes(Component.SPACE_SCOPE);
if (_self instanceof Page)
return ((Page)_self).getAttributes();
return Collections.EMPTY_MAP;
}
if (_self instanceof Component) {
final Component comp = (Component)_self;
//We have to look getZScriptVariable first and then namespace
//so it is in the same order of interpreter
final Page page = getPage(comp);
if (page != null) {
final Object o =
page.getZScriptVariable(comp, name);
if (o != null)
return o;
}
Object o = _exec.getAttribute(name);
if (o != null || _exec.hasAttribute(name))
return o;
o = comp.getAttributeOrFellow(name, true);
if (o != null)
return o;
if (page != null) {
o = page.getXelVariable(ctx, null, name, true);
if (o != null)
return o;
}
} else {
Page page;
if (_self instanceof Page) {
page = (Page)_self;
} else {
page = ((ExecutionCtrl)_exec).getCurrentPage();
}
if (page != null) {
Object o = page.getZScriptVariable(name);
if (o != null)
return o;
o = _exec.getAttribute(name);
if (o != null || _exec.hasAttribute(name))
return o;
o = page.getAttributeOrFellow(name, true);
if (o != null)
return o;
o = page.getXelVariable(ctx, null, name, true);
if (o != null)
return o;
} else {
Object o = _exec.getAttribute(name, true);
if (o != null || _exec.hasAttribute(name, true))