List of usage examples for javax.el ELException ELException
public ELException(Throwable cause)
From source file:de.openknowledge.extensions.jsf.model.ModelMethod.java
@Override public void updateModel(FacesContext context) { ValueExpression expression = getValueExpression("value"); SimpleMethodExpressionParser parser = new SimpleMethodExpressionParser(expression.getExpressionString()); SimpleMethodExpression methodExpression = parser.parse(); ExpressionFactory expressionFactory = notNull(context, "context may not be null").getApplication() .getExpressionFactory();//from www .jav a2 s . co m ValueExpression baseExpression = expressionFactory.createValueExpression(context.getELContext(), "#{" + methodExpression.getBase() + '}', Object.class); Object baseValue = baseExpression.getValue(context.getELContext()); Class<? extends Object> baseType = baseValue.getClass(); UIInput[] parameterComponents = findComponents(methodExpression); Class<?>[] parameterTypes = findParameterTypes(context, methodExpression, expressionFactory, parameterComponents); Method method = findMethod(baseType, methodExpression.getMethodName(), parameterTypes); Object[] parameters = findParameters(context, methodExpression, expressionFactory, parameterComponents, parameterTypes); try { method.invoke(baseValue, parameters); } catch (InvocationTargetException e) { throw new ELException(e.getTargetException()); } catch (Exception e) { throw new ELException(e); } }
From source file:de.openknowledge.extensions.el.SimpleMethodExpressionParser.java
private String parseToken() { int start = -1; String token = null;/* w w w .j a v a2 s.c o m*/ for (String t : TOKENS) { int index = input.lastIndexOf(t); if (index > start) { start = index; token = t; } } if (token == null) { throw new ELException("expected text, but found " + input); } String text = input.substring(start + token.length()); input = input.substring(0, start + 1); return text; }
From source file:de.openknowledge.extensions.el.SimpleMethodExpressionParser.java
private void consume(String token) { input = input.trim();/* w w w. j a v a 2s .c o m*/ if (!input.endsWith(token)) { throw new ELException("expected " + token + ", but found " + input); } input = input.substring(0, input.lastIndexOf(token)); }
From source file:de.openknowledge.extensions.jsf.model.ModelMethod.java
private Method findMethod(Class<?> type, String name, Class<?>[] parameters) { for (Method method : type.getMethods()) { if (method.getName().equals(name)) { Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length != parameters.length) { continue; }/*from www. j av a2 s .c o m*/ boolean match = true; for (int i = 0; i < parameters.length; i++) { if (parameters[i] != null && !parameterTypes[i].isAssignableFrom(parameters[i])) { match = false; break; } } if (match) { // TODO currently we simply take the first match... We should resolve based on java resolution rules... return method; } } } throw new ELException("method with name '" + name + "' not found in type " + type.getName()); }
From source file:org.apache.shindig.expressions.OpensocialFunctions.java
/** * Convert a string to a JSON Object or JSON Array. */// w ww .j a v a2 s . c o m @Functions.Expose(prefix = "osx", names = { "parseJson" }) public static Object parseJson(String text) { if ((text == null) || "".equals(text)) { return null; } try { if (text.startsWith("[")) { return new JSONArray(text); } else { return new JSONObject(text); } } catch (JSONException je) { throw new ELException(je); } }
From source file:org.jbuilt.utils.ValueClosure.java
public Object getValue(ELContext elContext) throws ELException { this.elContext = elContext; if (elContext == null) { throw new NullPointerException("ELContext -> null"); }/* w w w . j a v a2 s . c o m*/ Object result = null; assert null != context; try { result = PropertyUtils.getProperty(bean, prop); } catch (Throwable e) { throw new ELException(e); } return result; }
From source file:org.jbuilt.utils.ValueClosure.java
public void setValue(ELContext elContext, Object value) throws ELException { if (elContext == null) { throw new NullPointerException("ELContext -> null"); }//from w w w .j a v a 2 s . c o m assert null != context; try { PropertyUtils.setProperty(bean, prop, ((ValueClosure) value).getValue()); } catch (Throwable e) { throw new ELException(e); } }
From source file:org.jbuilt.utils.ValueClosure.java
public boolean isReadOnly(ELContext elContext) throws ELException { if (elContext == null) { throw new NullPointerException("ELContext -> null"); }//from www .jav a 2s. c o m boolean result = false; assert null != context; try { result = isReadOnly(bean, prop); } catch (Throwable e) { throw new ELException(e); } return result; }
From source file:org.jbuilt.utils.ValueClosure.java
public Class<?> getType(ELContext elContext) throws ELException { if (elContext == null) { throw new NullPointerException("ELContext -> null"); }/* w ww . j av a2 s .c om*/ Class result = null; assert null != context; try { result = getType(this.bean, this.prop); } catch (Throwable e) { throw new ELException(e); } return result; }
From source file:org.jbuilt.utils.ValueClosure.java
public Class<?> getType(Object bean, String prop) throws ELException { Class result = null;/*from ww w. j ava 2s.c o m*/ try { result = PropertyUtils.getPropertyType(bean, prop); } catch (Throwable e) { throw new ELException(e); } return result; }