Example usage for javax.el ELContext getELResolver

List of usage examples for javax.el ELContext getELResolver

Introduction

In this page you can find the example usage for javax.el ELContext getELResolver.

Prototype

public abstract ELResolver getELResolver();

Source Link

Usage

From source file:edu.eci.pdsw.samples.managedbeans.PagoAfiliacionBean.java

public static Object getManagedBean(final String beanName) {
    FacesContext fc = FacesContext.getCurrentInstance();

    Object bean;//from  ww w. j  a  v  a2  s  .  c  om
    try {
        ELContext elContext = fc.getELContext();
        bean = elContext.getELResolver().getValue(elContext, null, beanName);
    } catch (RuntimeException e) {
        throw new FacesException(e.getMessage(), e);

    }
    return bean;
}

From source file:eu.planets_project.tb.impl.model.eval.PropertyEvaluation.java

private static String lookupName(EquivalenceStatement state) {
    try {//  www .  j a v a 2s.c o m
        ELContext elContext = FacesContext.getCurrentInstance().getELContext();
        // Load the resource bundle:
        ResourceBundle bundle = null;
        /*
        try {
        Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
        bundle = ResourceBundle.getBundle("eu.planets_project.tb.gui.UIResources", locale );
        } catch ( MissingResourceException e ) {
        log.error("Could not load resource bundle: "+e);
        }
        */
        Map map = (Map) elContext.getELResolver().getValue(elContext, null, "res");
        // Look up
        String label = state.toString();
        String key = "exp_stage5.evaluation." + label;
        String name = (String) map.get(key);
        if (bundle != null)
            label = bundle.getString(key);
        //log.info("For "+state+" got "+label+" and "+name);
        if (name != null)
            label = name;
        return label;
    } catch (Exception e) {
        log.error("Failure when looking up " + state + " :: " + e);
        return state.toString();
    }
}

From source file:es.urjc.mctwp.bbeans.AbstractBean.java

/**
 * Returns BackBean reference by given name
 * //from w  w w.  j a  v  a2s  . com
 * @param backBean
 */
public Object getBackBeanReference(String backBean) {
    ELContext context = getFacesContext().getELContext();
    return context.getELResolver().getValue(context, null, backBean);
}

From source file:com.sisrni.converter.FacultadUnidadConverter.java

@Override
public Object getAsObject(FacesContext fc, UIComponent uic, String submittedValue) {
    if (submittedValue.trim().equals("")) {
        return null;
    } else {//  ww  w  .j  a  v a 2  s  .  co m
        try {
            if (isNumeric(submittedValue)) {
                if (submittedValue != null) {
                    int number = Integer.parseInt(submittedValue);
                    ELContext elContext = FacesContext.getCurrentInstance().getELContext();
                    PropuestaConvenioMB firstBean = (PropuestaConvenioMB) elContext.getELResolver()
                            .getValue(elContext, null, "propuestaConvenioMB");

                    listaFacultadUnidad = firstBean.getListaFacultadUnidad();
                    for (PojoFacultadesUnidades s : listaFacultadUnidad) {
                        if (s.getId() == number) {
                            return s;
                        }
                    }
                }
            }
        } catch (NumberFormatException exception) {
            throw new ConverterException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error",
                    "Error FacultadUnidadConverter "));
        }
    }

    return null;
}

From source file:org.richfaces.taglib.ColumnsTag.java

/**
 * Create custom context with VariableMapper override.
 * //  w w  w . j  ava2s. c  om
 * @param context
 * @return
 */
private ELContext getContext(final ELContext cont) {
    return new ELContext() {

        @Override
        public Object getContext(Class key) {
            return cont.getContext(key);
        }

        @Override
        public ELResolver getELResolver() {
            return cont.getELResolver();
        }

        @Override
        public FunctionMapper getFunctionMapper() {
            return cont.getFunctionMapper();
        }

        @Override
        public VariableMapper getVariableMapper() {
            return new VariableMapper() {

                @Override
                public ValueExpression resolveVariable(String variable) {
                    if (variable.equals(itemId)) {
                        return new IndexedValueExpression(__value, index);
                    } else if (variable.equals(indexId)) {
                        return new IteratedIndexExpression(index);
                    }
                    return cont.getVariableMapper().resolveVariable(variable);
                }

                @Override
                public ValueExpression setVariable(String variable, ValueExpression expression) {
                    return cont.getVariableMapper().setVariable(variable, expression);
                }

            };
        }

    };
}

From source file:therian.uelbox.ELContextWrapper.java

/**
 * Create a new ELContextWrapper./*from  w w  w.ja va2 s.c o  m*/
 * 
 * @param wrapped
 */
protected ELContextWrapper(ELContext wrapped) {
    this.wrapped = Validate.notNull(wrapped, "wrapped ELContext");
    this.elResolver = Validate.notNull(wrap(wrapped.getELResolver()));
    this.variableMapper = new SimpleVariableMapper() {
        @Override
        public ValueExpression resolveVariable(String variable) {
            if (containsVariable(variable)) {
                return super.resolveVariable(variable);
            }
            return ELContextWrapper.this.wrapped.getVariableMapper().resolveVariable(variable);
        }
    };
}