List of usage examples for javax.el ValueExpression getValue
public abstract Object getValue(ELContext context);
From source file:com.github.persapiens.jsfboot.security.AuthorizeFaceletsTag.java
private String getAttributeValue(FaceletContext faceletContext, TagAttribute tagAttribute, boolean evaluate) { String value = null;//w w w . j av a2 s . co m if (tagAttribute != null) { if (evaluate) { ValueExpression expression = tagAttribute.getValueExpression(faceletContext, String.class); value = (String) expression.getValue(faceletContext.getFacesContext().getELContext()); } else { value = tagAttribute.getValue(); } } return value; }
From source file:org.nuxeo.ecm.platform.actions.jsf.JSFActionContext.java
@Override public boolean checkCondition(String expression) throws ELException { if (StringUtils.isBlank(expression) || (expression != null && StringUtils.isBlank(expression.trim()))) { return false; }// w w w . j a v a 2 s . c om String expr = expression.trim(); // compatibility code, as JEXL could resolve that kind of expression: // detect if expression is in brackets #{}, otherwise add it if (!expr.startsWith("#{") && !expr.startsWith("${") // don't confuse error messages in case of simple mistakes in the // expression && !expr.endsWith("}")) { expr = "#{" + expr + "}"; } ELContext finalContext = new JSFELContext(originalContext); VariableMapper vm = finalContext.getVariableMapper(); // init default variables ValueExpression documentExpr = expressionFactory.createValueExpression(getCurrentDocument(), DocumentModel.class); ValueExpression userExpr = expressionFactory.createValueExpression(getCurrentPrincipal(), NuxeoPrincipal.class); vm.setVariable("actionContextDocument", documentExpr); // add variables originally exposed by the action framework, // do not add aliases currentDocument and currentUser here as they // should already be available in this JSF context vm.setVariable("document", documentExpr); vm.setVariable("principal", userExpr); // get custom context from ActionContext for (String key : localVariables.keySet()) { vm.setVariable(key, expressionFactory.createValueExpression(getLocalVariable(key), Object.class)); } // expose Seam context for compatibility, although available its // components should be natively exposed in this JSF context putLocalVariable("SeamContext", new SeamContextHelper()); // evaluate expression ValueExpression ve = expressionFactory.createValueExpression(finalContext, expr, Boolean.class); return Boolean.TRUE.equals(ve.getValue(finalContext)); }
From source file:org.apache.camel.language.juel.JuelExpression.java
public <T> T evaluate(Exchange exchange, Class<T> tClass) { // TODO we could use caching here but then we'd have possible concurrency issues // so lets assume that the provider caches // Create (if needed) the ExpressionFactory first from the CamelContext using FactoryFinder ExpressionFactory factory = getExpressionFactory(exchange.getContext()); ELContext context = populateContext(createContext(), exchange); ValueExpression valueExpression = factory.createValueExpression(context, expression, type); Object value = valueExpression.getValue(context); return exchange.getContext().getTypeConverter().convertTo(tClass, value); }
From source file:org.nuxeo.ecm.platform.ui.web.binding.alias.AliasValueExpression.java
/** * Looks up the {@link AliasVariableMapper} in the context, and if found, resolve the corresponding * {@link ValueExpression}./*w ww . j av a 2 s . c o m*/ */ @Override public Object getValue(ELContext context) { ValueExpression ve = resolveExpression(context); Object res = null; if (ve != null) { res = ve.getValue(context); } if (log.isDebugEnabled()) { log.debug("Resolved expression var='" + var + "' for mapper with id '" + id + "': " + res); } return res; }
From source file:org.nuxeo.ecm.platform.ui.web.directory.UIDirectorySelectItem.java
public String getDirectoryName() { if (directoryName != null) { return directoryName; }/*from w w w. ja v a 2 s. com*/ ValueExpression ve = getValueExpression("directoryName"); if (ve != null) { try { return (String) ve.getValue(getFacesContext().getELContext()); } catch (ELException e) { throw new FacesException(e); } } else { // default value return null; } }
From source file:velo.uiComponents.XMLManager.java
public String getFilename() { if (this.filename != null) return this.filename; ValueExpression vb = this.getValueExpression("filename"); if (vb != null) return (String) vb.getValue(FacesContext.getCurrentInstance().getELContext()); return null;/*from ww w . j a v a 2 s. c om*/ }
From source file:org.nuxeo.ecm.platform.ui.web.component.editor.UIHtmlEditor.java
public String getCols() { if (cols != null) { return cols; }/*from www . j a v a 2 s . co m*/ ValueExpression ve = getValueExpression("cols"); if (ve != null) { try { return (String) ve.getValue(getFacesContext().getELContext()); } catch (ELException e) { throw new FacesException(e); } } else { // default value return "100"; } }
From source file:org.nuxeo.ecm.platform.ui.web.component.editor.UIHtmlEditor.java
public String getRows() { if (rows != null) { return rows; }/*w w w . ja v a 2 s. c o m*/ ValueExpression ve = getValueExpression("rows"); if (ve != null) { try { return (String) ve.getValue(getFacesContext().getELContext()); } catch (ELException e) { throw new FacesException(e); } } else { // default value return "25"; } }
From source file:org.nuxeo.ecm.platform.ui.web.component.editor.UIHtmlEditor.java
public String getWidth() { if (width != null) { return width; }// www . j a va 2s . c o m ValueExpression ve = getValueExpression("width"); if (ve != null) { try { return (String) ve.getValue(getFacesContext().getELContext()); } catch (ELException e) { throw new FacesException(e); } } else { // default value return "640"; } }
From source file:org.nuxeo.ecm.platform.ui.web.component.editor.UIHtmlEditor.java
public String getHeight() { if (height != null) { return height; }/* w w w. ja v a 2 s . c om*/ ValueExpression ve = getValueExpression("height"); if (ve != null) { try { return (String) ve.getValue(getFacesContext().getELContext()); } catch (ELException e) { throw new FacesException(e); } } else { // default value return "400"; } }