/** * {@inheritDoc} */ @Override public String resolve(String expression) { ValueExpression expr = expressionFactory.createValueExpression(elContext, expression, String.class); return String.valueOf(expr.getValue(elContext)); } }
public boolean isRTL() { if (rtl == null) { String param = context.getExternalContext().getInitParameter(Constants.ContextParams.DIRECTION); if (param == null) { rtl = false; } else { ELContext elContext = context.getELContext(); ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory(); ValueExpression expression = expressionFactory.createValueExpression(elContext, param, String.class); String expressionValue = (String) expression.getValue(elContext); rtl = (expressionValue == null) ? false : expressionValue.equalsIgnoreCase("rtl"); } } return rtl; } }
@Override public Object evaluateExpressionGet(FacesContext ctx, String expr, Class type) throws ELException { return getExpressionFactory().createValueExpression( ctx.getELContext(), expr, type).getValue( ctx.getELContext() ); }
public String resolveDynamicField(ValueExpression expression) { if (expression == null) { return null; } FacesContext context = getFacesContext(); ELContext elContext = context.getELContext(); String expressionString = expression.getExpressionString(); // old syntax compatibility // #{car[column.property]} // new syntax is: // #{column.property} or even a method call if (expressionString.startsWith("#{" + getVar() + "[")) { expressionString = expressionString.substring(expressionString.indexOf("[") + 1, expressionString.indexOf("]")); expressionString = "#{" + expressionString + "}"; ValueExpression dynaVE = context.getApplication() .getExpressionFactory().createValueExpression(elContext, expressionString, String.class); return (String) dynaVE.getValue(elContext); } return (String) expression.getValue(elContext); }
@Override public Object evaluateExpressionGet(FacesContext context, String expression, Class type) throws javax.el.ELException { return getExpressionFactory().createValueExpression(context.getELContext(), expression, type).getValue(context.getELContext()); }
/** * {@inheritDoc} */ @Override public String resolve(String expression) { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { ClassLoader newTccl = classLoader == null ? ELExpressionFactory.class.getClassLoader() : classLoader; Thread.currentThread().setContextClassLoader(newTccl); ValueExpression expr = expressionFactory.createValueExpression(elContext, expression, String.class); return String.valueOf(expr.getValue(elContext)); } finally { Thread.currentThread().setContextClassLoader(tccl); } } }
ELContext eLContext = context.getELContext(); ValueExpression ve = context.getApplication().getExpressionFactory().createValueExpression( context.getELContext(), dynamicContentEL, StreamedContent.class); streamedContent = (StreamedContent) ve.getValue(eLContext);
@SuppressWarnings("unchecked") @Override public final <T> T evaluateExpressionGet(final FacesContext context, final String expression, final Class<? extends T> expectedType) throws ELException { ELContext elContext = context.getELContext(); ExpressionFactory factory = getExpressionFactory(); return (T) factory.createValueExpression(elContext, expression, expectedType).getValue(elContext); }
/** * Evaluates the condition * * @param condition the condition expression * @param entity the entity returned from the resource method * @param resource the resource class instance that returned the entity * @param instance the instance that contains the entity, e.g. the value of a field within an entity class. * @return the result of the condition */ static boolean evaluateCondition(String condition, Object entity, Object resource, Object instance) { if (condition == null || condition.isEmpty()) { return true; } LinkELContext context = new LinkELContext(entity, resource, instance); ValueExpression expr = expressionFactory.createValueExpression(context, condition, boolean.class); Object result = expr.getValue(context).toString(); return "true".equals(result); }
ResponseWriter writer = context.getResponseWriter(); PrimeApplicationContext applicationContext = PrimeApplicationContext.getCurrentInstance(context); ProjectStage projectStage = context.getApplication().getProjectStage(); boolean csvEnabled = applicationContext.getConfig().isClientSideValidationEnabled(); ELContext elContext = context.getELContext(); ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory(); ValueExpression ve = expressionFactory.createValueExpression(elContext, themeParamValue, String.class); theme = (String) ve.getValue(elContext);
@SuppressWarnings("unchecked") // Forced cast on T @Override public <T> T evaluateExpressionGet(FacesContext context, String expression, Class<? extends T> expectedType) throws ELException { ValueExpression ve = getExpressionFactory().createValueExpression(context.getELContext(), expression, expectedType); return (T) (ve.getValue(context.getELContext())); } }
private static Map<String, Object> getParameterValues(List<String> parameterNames, InjectLinkDescriptor linkField, LinkELContext context, UriInfo uriInfo) { Map<String, Object> values = new HashMap<>(); for (String name : parameterNames) { String elExpression = linkField.getBinding(name); if (elExpression == null) { String value = uriInfo.getPathParameters().getFirst(name); if (value == null) { value = uriInfo.getQueryParameters().getFirst(name); } if (value != null) { values.put(name, value); continue; } elExpression = "${" + ResponseContextResolver.INSTANCE_OBJECT + "." + name + "}"; } ValueExpression expr = expressionFactory.createValueExpression(context, elExpression, String.class); Object value = expr.getValue(context); values.put(name, value != null ? value.toString() : null); } return values; }
SummaryRow summaryRow = table.getSummaryRow(); HeaderRow headerRow = table.getHeaderRow(); ELContext eLContext = context.getELContext(); ValueExpression groupByVE = null; ValueExpression tableSortByVE = table.getValueExpression(DataTable.PropertyKeys.sortBy.toString()); groupByVE = (table.getSortBy() == null || table.isMultiSort()) ? null : context.getApplication().getExpressionFactory().createValueExpression( eLContext, "#{" + table.getVar() + "." + table.getSortBy() + "}", Object.class);
@Override public Object evaluateExpressionGet(FacesContext context, String expression, Class type) throws javax.el.ELException { return getExpressionFactory().createValueExpression(context.getELContext(), expression, type).getValue(context.getELContext()); }
/** * Evaluates an EL expression, and coerces the result to the specified type. * @param expression The EL expression to be evaluated. * @param expectedType Specifies the type that the resultant evaluation * will be coerced to. * @return The result of the expression evaluation. */ public Object getValue(String expression, Class<?> expectedType) { ValueExpression exp = factory.createValueExpression( elManager.getELContext(), bracket(expression), expectedType); return exp.getValue(elManager.getELContext()); }
private ValueExpression getValueExpression(FacesContext ctx) { if (valueExpression==null) { valueExpression = ctx.getApplication().getExpressionFactory() .createValueExpression( ctx.getELContext(), expressionString, Object.class ); } return valueExpression; } }
/** * @see javax.faces.application.Application#evaluateExpressionGet(javax.faces.context.FacesContext, * String, Class) */ @SuppressWarnings("unchecked") public <T> T evaluateExpressionGet(FacesContext context, String expression, Class<? extends T> expectedType) throws ELException { return (T) getExpressionFactory().createValueExpression(context.getELContext(), expression, expectedType).getValue(context.getELContext()); }
/** * Creates the URI using the link descriptor. * * @param link the link descriptor * @param entity the entity returned from the resource method * @param resource the resource class instance that returned the entity * @param instance the instance that contains the entity, e.g. the value of a field within an entity class. * @param uriInfo JAX-RS {@link UriInfo} * @param rmc the {@link ResourceMappingContext} * @return the URI */ static URI buildURI(InjectLinkDescriptor link, Object entity, Object resource, Object instance, UriInfo uriInfo, ResourceMappingContext rmc) { String template = link.getLinkTemplate(rmc); // first process any embedded EL expressions LinkELContext context = new LinkELContext(entity, resource, instance); ValueExpression expr = expressionFactory.createValueExpression(context, template, String.class); template = expr.getValue(context).toString(); // now process any embedded URI template parameters UriBuilder ub = applyLinkStyle(template, link.getLinkStyle(), uriInfo); UriTemplateParser parser = new UriTemplateParser(template); List<String> parameterNames = parser.getNames(); Map<String, Object> valueMap = getParameterValues(parameterNames, link, context, uriInfo); return ub.buildFromMap(valueMap); }
private ValueExpression _getToViewIdExpression(FacesContext context) { assert _toViewId != null; if (_toViewIdExpression == null) { ExpressionFactory factory = context.getApplication().getExpressionFactory(); _toViewIdExpression = factory.createValueExpression(context.getELContext(), _toViewId, String.class); } return _toViewIdExpression; }
/** {@inheritDoc} */ public Object evaluateExpressionGet(FacesContext context, String expression, Class expectedType) throws ELException { ValueExpression ve = getExpressionFactory().createValueExpression (context.getELContext(), expression, expectedType); return ve.getValue(context.getELContext()); }