List of usage examples for javax.el ValueExpression getValue
public abstract Object getValue(ELContext context);
From source file:org.directwebremoting.faces.Jsf2Creator.java
@Override public Object getInstance() throws InstantiationException { FacesContext facesContext = FacesContext.getCurrentInstance(); if (facesContext == null) { log.error("Object " + getManagedBeanName() + " cannot be created since the faces context is null"); return null; }// w ww . ja va 2s . co m Object resolvedObject = null; if (isVBExpression(getManagedBeanName())) { ValueExpression ve = facesContext.getApplication().getExpressionFactory().createValueExpression( facesContext.getELContext(), "#{" + getManagedBeanName() + "}", Object.class); if (null != ve) { resolvedObject = ve.getValue(facesContext.getELContext()); } } else { resolvedObject = facesContext.getELContext().getELResolver().getValue(facesContext.getELContext(), null, getManagedBeanName()); } return resolvedObject; }
From source file:biz.netcentric.cq.tools.actool.configreader.YamlMacroElEvaluator.java
public <T> T evaluateEl(String el, Class<T> expectedResultType, Map<? extends Object, ? extends Object> variables) { vars = variables;//from ww w .jav a2s . c o m ValueExpression expression = expressionFactory.createValueExpression(context, el, expectedResultType); T value = (T) expression.getValue(context); return value; }
From source file:org.nuxeo.ecm.platform.ui.web.component.editor.UIHtmlEditor.java
public String getEditorSelector() { if (editorSelector != null) { return editorSelector; }/* ww w . j av a 2 s.c o m*/ ValueExpression ve = getValueExpression("editorSelector"); if (ve != null) { try { return (String) ve.getValue(getFacesContext().getELContext()); } catch (ELException e) { throw new FacesException(e); } } else { // default value return "mceEditor"; } }
From source file:org.nuxeo.ecm.platform.ui.web.binding.MetaValueExpression.java
@Override public Object getValue(ELContext context) { ELContext nxcontext = getLocalContext(context); Object res = null;//from w w w .j ava2s. co m if (originalValueExpression != null) { res = originalValueExpression.getValue(nxcontext); if (res instanceof String) { String expression = (String) res; if (ComponentTagUtils.isValueReference(expression)) { FacesContext faces = FacesContext.getCurrentInstance(); Application app = faces.getApplication(); ExpressionFactory factory = app.getExpressionFactory(); ValueExpression newExpr = factory.createValueExpression(nxcontext, expression, expectedType); try { res = newExpr.getValue(nxcontext); } catch (ELException err) { log.error("Error processing expression " + expression + ": " + err); res = null; } } else { res = expression; } } } return res; }
From source file:velo.uiComponents.XMLManager.java
public String getXmlContent() { if (this.xmlContent != null) { return this.xmlContent; }/*from w w w .j ava 2 s. co m*/ ValueExpression ve = getValueExpression("xmlContent"); if (ve != null) { try { return (String) ve.getValue(getFacesContext().getELContext()); } catch (ELException e) { throw new FacesException(e); } } else { return null; } }
From source file:gwap.game.quiz.PlayNCommunicationResource.java
/** * Sets up a new Quiz Game Session//from w ww . j a v a2 s . c o m * * @return gameArray Array for JSON */ private JSONObject createJSONObjectForNewGame() { try { /* * setting up dummy JSF FacesContext */ if (Transaction.instance().getStatus() == Status.STATUS_NO_TRANSACTION) { Transaction.instance().begin(); } // Conversation.instance().begin(); FacesContext facesContext = new FacesContextBuilder().getFacesContext(request, response, request.getSession()); this.elc = facesContext.getELContext(); this.elFactory = facesContext.getApplication().getExpressionFactory(); ValueExpression mexp = elFactory.createValueExpression(elc, "#{quizSession}", QuizSessionBean.class); this.quizSessionBean = (QuizSessionBean) mexp.getValue(elc); ses.setAttribute("quizSession", quizSessionBean); JSONObject jsonResult = quizSessionBean.getJSONResult(); facesContext.release(); Transaction.instance().commit(); return jsonResult; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.flexive.faces.components.content.Jsf2FxValueHandler.java
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException { final String var; try {//from w w w. j a v a 2 s . c om if (this.getAttribute("var") == null) { // no variable name specified, use enclosing content view if (!(parent instanceof FxContentView)) { throw new FacesException( "Facelet parent is no FxContentView instance and \"var\" attribute not specified."); } var = ((FxContentView) parent).getVar(); } else { // use a custom variable name var = this.getAttribute("var").getValue(ctx); } } catch (FxRuntimeException e) { throw new FacesException("The fx:value component must be embedded in a fx:content instance."); } final boolean isNewValue = this.getAttribute("new") != null && Boolean.valueOf(this.getAttribute("new").getValue(ctx)); final VariableMapper origMapper = ctx.getVariableMapper(); final VariableMapperWrapper mapper = new VariableMapperWrapper(origMapper); try { ctx.setVariableMapper(mapper); // get property attribute final String property; final TagAttribute propertyAttribute = this.getAttribute("property"); if (propertyAttribute != null) { final ValueExpression propertyExpression = propertyAttribute.getValueExpression(ctx, String.class); property = (String) propertyExpression.getValue(ctx); } else { property = null; } FxJsfComponentUtils.requireAttribute("fx:value", "property", property); // assign id, label/labelKey and value based on the enclosing FxContentView instance final ExpressionFactory expressionFactory = ctx.getExpressionFactory(); mapper.setVariable("id", expressionFactory.createValueExpression(StringUtils.replace(property, "/", "_"), String.class)); if (this.getAttribute("labelKey") == null) { // use property label mapper.setVariable("label", expressionFactory.createValueExpression(ctx, FxContentView.getExpression(var, property, "label"), FxString.class)); } else { // use provided message key assignAttribute(ctx, mapper, "labelKey", String.class); } // retrieve content from content view mapper.setVariable("value", expressionFactory.createValueExpression(ctx, FxContentView.getExpression(var, property, isNewValue ? "new" : null), FxValue.class)); // passthrough other template attributes assignAttribute(ctx, mapper, "inputMapper", InputMapper.class); assignAttribute(ctx, mapper, "onchange", String.class); assignAttribute(ctx, mapper, "readOnly", Boolean.class); assignAttribute(ctx, mapper, "decorate", Boolean.class); assignAttribute(ctx, mapper, "filter", Boolean.class); assignAttribute(ctx, mapper, "forceLineInput", Boolean.class); assignAttribute(ctx, mapper, "valueFormatter", FxValueFormatter.class); assignAttribute(ctx, mapper, "containerDivClass", String.class); assignAttribute(ctx, mapper, "autocompleteHandler", String.class); assignAttribute(ctx, mapper, "disableMultiLanguage", Boolean.class); assignAttribute(ctx, mapper, "disableLytebox", Boolean.class); assignAttribute(ctx, mapper, "tooltip", String.class); assignAttribute(ctx, mapper, "tooltipKey", String.class); // TODO: cache templates/use a facelet ResourceResolver to encapsulate this ctx.includeFacelet(parent, Thread.currentThread().getContextClassLoader().getResource(TEMPLATE_ROOT + template)); } finally { ctx.setVariableMapper(origMapper); } }
From source file:com.flexive.faces.components.content.FxValueHandler.java
@Override public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, ELException { final String var; try {/*from www .j a va 2s .c om*/ if (this.getAttribute("var") == null) { // no variable name specified, use enclosing content view if (!(parent instanceof FxContentView)) { throw new FacesException( "Facelet parent is no FxContentView instance and \"var\" attribute not specified."); } var = ((FxContentView) parent).getVar(); } else { // use a custom variable name var = this.getAttribute("var").getValue(ctx); } } catch (FxRuntimeException e) { throw new FacesException("The fx:value component must be embedded in a fx:content instance."); } final boolean isNewValue = this.getAttribute("new") != null && Boolean.valueOf(this.getAttribute("new").getValue(ctx)); final VariableMapper origMapper = ctx.getVariableMapper(); final VariableMapperWrapper mapper = new VariableMapperWrapper(origMapper); try { ctx.setVariableMapper(mapper); // get property attribute final String property; final TagAttribute propertyAttribute = this.getAttribute("property"); if (propertyAttribute != null) { final ValueExpression propertyExpression = propertyAttribute.getValueExpression(ctx, String.class); property = (String) propertyExpression.getValue(ctx); } else { property = null; } FxJsfComponentUtils.requireAttribute("fx:value", "property", property); // assign id, label/labelKey and value based on the enclosing FxContentView instance final ExpressionFactory expressionFactory = ctx.getExpressionFactory(); mapper.setVariable("id", expressionFactory.createValueExpression(StringUtils.replace(property, "/", "_"), String.class)); if (this.getAttribute("labelKey") == null) { // use property label mapper.setVariable("label", expressionFactory.createValueExpression(ctx, FxContentView.getExpression(var, property, "label"), FxString.class)); } else { // use provided message key assignAttribute(ctx, mapper, "labelKey", String.class); } // retrieve content from content view mapper.setVariable("value", expressionFactory.createValueExpression(ctx, FxContentView.getExpression(var, property, isNewValue ? "new" : null), FxValue.class)); // passthrough other template attributes assignAttribute(ctx, mapper, "inputMapper", InputMapper.class); assignAttribute(ctx, mapper, "onchange", String.class); assignAttribute(ctx, mapper, "readOnly", Boolean.class); assignAttribute(ctx, mapper, "decorate", Boolean.class); assignAttribute(ctx, mapper, "filter", Boolean.class); assignAttribute(ctx, mapper, "forceLineInput", Boolean.class); assignAttribute(ctx, mapper, "newLine", Boolean.class); assignAttribute(ctx, mapper, "valueFormatter", FxValueFormatter.class); assignAttribute(ctx, mapper, "containerDivClass", String.class); assignAttribute(ctx, mapper, "autocompleteHandler", String.class); assignAttribute(ctx, mapper, "disableMultiLanguage", Boolean.class); assignAttribute(ctx, mapper, "disableLytebox", Boolean.class); assignAttribute(ctx, mapper, "tooltip", String.class); assignAttribute(ctx, mapper, "tooltipKey", String.class); // TODO: cache templates/use a facelet ResourceResolver to encapsulate this ctx.includeFacelet(parent, Thread.currentThread().getContextClassLoader().getResource(TEMPLATE_ROOT + template)); } finally { ctx.setVariableMapper(origMapper); } }
From source file:org.nuxeo.ecm.platform.ui.web.component.date.UIInputDateTime.java
protected String getStringValue(String name, String defaultValue) { ValueExpression ve = getValueExpression(name); if (ve != null) { try {/* w w w.ja va 2 s . c o m*/ return (String) ve.getValue(getFacesContext().getELContext()); } catch (ELException e) { throw new FacesException(e); } } else { return defaultValue; } }
From source file:org.nuxeo.ecm.platform.ui.web.component.date.UIInputDateTime.java
public String getLocale() { if (locale != null) { return locale; }/* www . j ava2 s. c o m*/ ValueExpression ve = getValueExpression("locale"); if (ve != null) { try { return (String) ve.getValue(getFacesContext().getELContext()); } catch (ELException e) { throw new FacesException(e); } } else { return null; } }