use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class ComponentImpl method _set.
/**
* sets a value to the current Component, dont to base Component
* @param key
* @param value
* @return value set
* @throws ExpressionException
*/
private Object _set(PageContext pc, Collection.Key key, Object value) throws ExpressionException {
if (value instanceof Member) {
if (value instanceof UDFPlus) {
UDFPlus udf = (UDFPlus) ((UDFPlus) value).duplicate();
// udf.isComponentMember(true);///+++
udf.setOwnerComponent(this);
if (udf.getAccess() > Component.ACCESS_PUBLIC)
udf.setAccess(Component.ACCESS_PUBLIC);
_data.put(key, udf);
_udfs.put(key, udf);
hasInjectedFunctions = true;
} else
_data.put(key, (Member) value);
} else {
Member existing = _data.get(key);
if (loaded && !isAccessible(pc, existing != null ? existing.getAccess() : dataMemberDefaultAccess))
throw new ExpressionException("Component [" + getCallName() + "] has no accessible Member with name [" + key + "]", "enable [trigger data member] in admininistrator to also invoke getters and setters");
_data.put(key, new DataMember(existing != null ? existing.getAccess() : dataMemberDefaultAccess, existing != null ? existing.getModifier() : Member.MODIFIER_NONE, value));
}
return value;
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class ComponentImpl method get.
public Object get(int access, Collection.Key key) throws PageException {
Member member = getMember(access, key, true, false);
if (member != null)
return member.getValue();
// Trigger
PageContext pc = ThreadLocalPageContext.get();
if (triggerDataMember(pc) && !isPrivate(pc)) {
return callGetter(pc, key);
}
throw new ExpressionException("Component [" + getCallName() + "] has no accessible Member with name [" + key + "]");
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class PageContextImpl method _param.
private void _param(String type, String name, Object defaultValue, double min, double max, String strPattern, int maxLength) throws PageException {
// check attributes name
if (StringUtil.isEmpty(name))
throw new ExpressionException("The attribute name is required");
Object value = null;
boolean isNew = false;
// get value
value = VariableInterpreter.getVariableEL(this, name, NullSupportHelper.NULL(this));
if (NullSupportHelper.NULL(this) == value) {
if (defaultValue == null)
throw new ExpressionException("The required parameter [" + name + "] was not provided.");
value = defaultValue;
isNew = true;
}
subparam(type, name, value, min, max, strPattern, maxLength, isNew);
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class CustomTagUtil method loadInitFile.
public static InitFile loadInitFile(PageContext pc, String name) throws PageException {
InitFile initFile = loadInitFile(pc, name, null);
if (initFile != null) {
return initFile;
}
// EXCEPTION
ConfigWeb config = pc.getConfig();
// message
StringBuilder msg = new StringBuilder("Custom tag \"").append(getDisplayName(config, name)).append("\" was not found.");
List<String> dirs = new ArrayList();
if (config.doLocalCustomTag()) {
dirs.add(ResourceUtil.getResource(pc, pc.getCurrentPageSource()).getParent());
}
Mapping[] actms = pc.getApplicationContext().getCustomTagMappings();
Mapping[] cctms = config.getCustomTagMappings();
Resource r;
if (actms != null) {
for (Mapping m : actms) {
r = m.getPhysical();
if (r != null)
dirs.add(r.toString());
}
}
if (cctms != null) {
for (Mapping m : cctms) {
r = m.getPhysical();
if (r != null)
dirs.add(r.toString());
}
}
if (!dirs.isEmpty()) {
msg.append(" Directories searched: ");
Iterator<String> it = dirs.iterator();
while (it.hasNext()) {
msg.append('"').append(it.next()).append('"');
if (it.hasNext())
msg.append(", ");
}
}
throw new ExpressionException(msg.toString());
}
use of lucee.runtime.exp.ExpressionException in project Lucee by lucee.
the class ComponentLoader method _search.
private static Object _search(PageContext pc, PageSource loadingLocation, String rawPath, Boolean searchLocal, Boolean searchRoot, boolean executeConstr, short returnType, final boolean isExtendedComponent) throws PageException {
PageSource currPS = pc.getCurrentPageSource(null);
ImportDefintion[] importDefintions = null;
if (currPS != null) {
Page currP;
Component cfc = pc.getActiveComponent();
if (cfc instanceof ComponentImpl && currPS.equals(cfc.getPageSource())) {
importDefintions = ((ComponentImpl) cfc)._getImportDefintions();
} else if ((currP = currPS.loadPage(pc, false, null)) != null) {
importDefintions = currP.getImportDefintions();
}
}
int dialect = currPS == null ? pc.getCurrentTemplateDialect() : currPS.getDialect();
// first try for the current dialect
Object obj = _search(pc, loadingLocation, rawPath, searchLocal, searchRoot, executeConstr, returnType, currPS, importDefintions, dialect, isExtendedComponent);
// then we try the opposite dialect
if (obj == null && ((ConfigImpl) pc.getConfig()).allowLuceeDialect()) {
// only when the lucee dialect is enabled we have to check the opposite
obj = _search(pc, loadingLocation, rawPath, searchLocal, searchRoot, executeConstr, returnType, currPS, importDefintions, dialect == CFMLEngine.DIALECT_CFML ? CFMLEngine.DIALECT_LUCEE : CFMLEngine.DIALECT_CFML, isExtendedComponent);
}
if (obj == null)
throw new ExpressionException("invalid " + toStringType(returnType, dialect) + " definition, can't find " + toStringType(returnType, dialect) + " [" + rawPath + "]");
return obj;
}
Aggregations