private Object getValue( FaceletContext faceletContext, UIComponent parent, String expressionString, String attributeName) { Class type = Object.class; try { type = PropertyUtils.getReadMethod( new PropertyDescriptor(attributeName, parent.getClass())).getReturnType(); } catch (IntrospectionException e) { LOG.warn("Can't determine expected type", e); } ExpressionFactory expressionFactory = faceletContext.getExpressionFactory(); final ValueExpression valueExpression = expressionFactory .createValueExpression(faceletContext, expressionString, type); return valueExpression.getValue(faceletContext); }
public String getText(FaceletContext ctx) { Writer writer = new FastWriter(this.length); try { this.txt.apply(ctx.getExpressionFactory(), ctx).write(writer, ctx); } catch (IOException e) { throw new ELException(this.alias + ": "+ e.getMessage(), e.getCause()); } return writer.toString(); }
/** * Create a ValueExpression, using this attribute's literal value and the * passed expected type. * * @see ExpressionFactory#createValueExpression(javax.el.ELContext, * java.lang.String, java.lang.Class) * @see ValueExpression * @param ctx * FaceletContext to use * @param type * expected return type * @return ValueExpression instance */ public ValueExpression getValueExpression(FaceletContext ctx, Class type) { try { ExpressionFactory f = ctx.getExpressionFactory(); return new TagValueExpression(this, f.createValueExpression(ctx, this.value, type)); } catch (Exception e) { throw new TagAttributeException(this, e); } }
public String getText(FaceletContext ctx) { Writer writer = new FastWriter(this.length); try { this.txt.apply(ctx.getExpressionFactory(), ctx).write(writer, ctx); } catch (IOException e) { throw new ELException(this.alias + ": "+ e.getMessage(), e.getCause()); } return writer.toString(); } }
public void applyMetadata(FaceletContext ctx, Object instance) { if (value == null) { String str = this.attribute.getValue(); value = new Object[] { ctx.getExpressionFactory().coerceToType(str, method.getParameterTypes()[0]) }; } try { method.invoke(instance, this.value); } catch (InvocationTargetException e) { throw new TagAttributeException(this.attribute, e.getCause()); } catch (Exception e) { throw new TagAttributeException(this.attribute, e); } }
/** * Create a MethodExpression, using this attribute's value as the expression * String. * * @see ExpressionFactory#createMethodExpression(javax.el.ELContext, * java.lang.String, java.lang.Class, java.lang.Class[]) * @see MethodExpression * @param ctx * FaceletContext to use * @param type * expected return type * @param paramTypes * parameter type * @return a MethodExpression instance */ public MethodExpression getMethodExpression(FaceletContext ctx, Class type, Class[] paramTypes) { try { ExpressionFactory f = ctx.getExpressionFactory(); return new TagMethodExpression(this, f.createMethodExpression(ctx, this.value, type, paramTypes)); } catch (Exception e) { throw new TagAttributeException(this, e); } }
} else { try { return ctx.getExpressionFactory().coerceToType(this.value, type); } catch (Exception e) {
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { if (parent != null) { try { ELText nt = this.txt.apply(ctx.getExpressionFactory(), ctx); UIComponent c = new UIText(this.alias, nt); c.setId(ComponentSupport.getViewRoot(ctx, parent).createUniqueId()); this.addComponent(ctx, parent, c); } catch (Exception e) { throw new ELException(this.alias + ": "+ e.getMessage(), e.getCause()); } } }
private MethodExpression getMethodExpression(FaceletContext faceletContext, Class returnType, Class[] args) { // in a composition may be we get the method expression string from the current variable mapper // the expression can be empty // in this case return nothing if (value.getValue().startsWith("${")) { ValueExpression expression = getExpression(faceletContext); if (expression != null) { ExpressionFactory expressionFactory = faceletContext.getExpressionFactory(); return new TagMethodExpression(value, expressionFactory.createMethodExpression(faceletContext, expression.getExpressionString(), returnType, args)); } else { return null; } } else { return value.getMethodExpression(faceletContext, returnType, args); } }
value = new Object[] { org.apache.myfaces.commons.util.TagUtils.getStringArray( ctx.getExpressionFactory().coerceToType( this.attr.getValue(), String.class)
for (int i = 0; i < size; i++) { ins = this.instructions[i]; applied[i] = ins.apply(ctx.getExpressionFactory(), ctx);
ExpressionFactory expressionFactory = faceletContext.getExpressionFactory(); MethodExpression action = new TagMethodExpression(value, expressionFactory.createMethodExpression( faceletContext, expressionString, String.class, ComponentUtils.ACTION_ARGS)); ExpressionFactory expressionFactory = faceletContext.getExpressionFactory(); MethodExpression actionListener = new TagMethodExpression(value, expressionFactory.createMethodExpression( faceletContext, expressionString, null, ComponentUtils.ACTION_LISTENER_ARGS));