Package javax.el

Examples of javax.el.ValueExpression


    }

    private void testLocation(String configuredValue, String expectedResolvedLocationExpression) {
        String expectedResolvedLocation = "evaluated_location";
        ExpressionFactory expressionFactory = mock(ExpressionFactory.class);
        ValueExpression valueExpression = mock(ValueExpression.class);

        // given
        configure(resourceMappingLocation, (String) expectedResolvedLocationExpression);
        when(application.getExpressionFactory()).thenReturn(expressionFactory);
        when(expressionFactory.createValueExpression(elContext, expectedResolvedLocationExpression, Object.class)).thenReturn(
                valueExpression);
        when(valueExpression.getValue(elContext)).thenReturn(expectedResolvedLocation);

        // when
        String location = ServiceTracker.getService(ResourceMappingConfiguration.class).getLocation();

        // then
View Full Code Here


                expressionFactory.createValueExpression(Mockito.any(ELContext.class), Mockito.anyString(),
                        Mockito.any(Class.class))).thenAnswer(new Answer<ValueExpression>() {
            @Override
            public ValueExpression answer(InvocationOnMock invocation) throws Throwable {
                final String expression = (String) invocation.getArguments()[1];
                ValueExpression valueExpression = mock(ValueExpression.class);
                when(valueExpression.getValue(elContext)).thenReturn(expression);
                return valueExpression;
            }
        });
    }
View Full Code Here

        Map<String, Object> attributes = Maps.newTreeMap();
        Object value = new Object();
        attributes.put("value", value);
        ELContext elContext = facesEnvironment.getElContext();

        ValueExpression valueExpression = facesEnvironment.createMock(ValueExpression.class);


        UIComponent component = createMockComponent();

        expect(facesContext.getELContext()).andReturn(elContext);
        expect(component.getValueExpression("value")).andReturn(valueExpression);
        expect(valueExpression.getValue(elContext)).andReturn(null);
        expect(component.getAttributes()).andReturn(attributes);

        facesEnvironment.replay();

        // when
View Full Code Here

        Object attributeValue = new Object();
        Object valueExpressionValue = new Object();
        attributes.put("value", attributeValue);
        ELContext elContext = facesEnvironment.getElContext();

        ValueExpression valueExpression = facesEnvironment.createMock(ValueExpression.class);

        UIComponent component = createMockComponent();

        expect(facesContext.getELContext()).andReturn(elContext);
        expect(component.getValueExpression("value")).andReturn(valueExpression);
        expect(valueExpression.getValue(elContext)).andReturn(valueExpressionValue);

        facesEnvironment.replay();

        // when
        Object evaluated = RenderKitUtils.evaluateAttribute("value", component, facesContext);
View Full Code Here

       * Validate the value against model-based constraints return true if the
       * value is valid
       */
      protected boolean validateValue(String valueExpression, Object value)
      {
         ValueExpression ve = application.getExpressionFactory().createValueExpression(facesContext.getELContext(), valueExpression, Object.class);
         InvalidValue[] ivs = Validators.instance().validate(ve, facesContext.getELContext(), value);
         if (ivs.length > 0)
         {
            validationFailed = true;
            facesContext.addMessage(null, FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, ivs[0].getMessage()));
View Full Code Here

        final FacesContext context = FacesContext.getCurrentInstance();

        String location = (String) context.getAttributes().get(KEY);

        if (location == null) {
            ValueExpression mappingLocationExpression = ELUtils.createValueExpression(getLocationAsExpression());
            location = mappingLocationExpression.getValue(FacesContext.getCurrentInstance().getELContext()).toString();

            context.getAttributes().put(KEY, location);
        }

        return location;
View Full Code Here

                result = new SelectItem(selectItem.getItemValue(), selectItem.getItemLabel(), selectItem.getItemDescription(),
                    selectItem.isItemDisabled(), selectItem.isItemEscaped(), selectItem.isNoSelectionOption());
            } else if (value instanceof SelectItem) {
                result = (SelectItem) value;
            } else {
                ValueExpression expression = selectItem.getValueExpression("value");
                throw new IllegalArgumentException("ValueExpression '"
                    + (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
                    + RichfacesLogger.getComponentPath(selectItem) + " does not reference an Object of type SelectItem");
            }

            return Iterators.singletonIterator(result);
        }
View Full Code Here

                Logger.Level level = Logger.Level.INFO;
                if (!context.isProjectStage(ProjectStage.Production)) {
                    level = Logger.Level.WARNING;
                }
                if (LOG.isLogEnabled(level)) {
                    ValueExpression expression = component.getValueExpression("value");
                    LOG.log(level, String.format("ValueExpression %s of UISelectItems with component-path %s"
                        + " does not reference an Object of type SelectItem," + " array, Iterable or Map, but of type: %s",
                        (expression == null ? null : expression.getExpressionString()),
                        RichfacesLogger.getComponentPath(component), (value == null ? null : value.getClass().getName())));
                }
            }

            return Iterators.emptyIterator();
View Full Code Here

     */
    public Object getProperty(String name) {
        Object property = themeProperties.get(name);

        if (property instanceof ValueExpression) {
            ValueExpression ve = (ValueExpression) property;

            property = ve.getValue(FacesContext.getCurrentInstance().getELContext());
        }

        return property;
    }
View Full Code Here

    }

    public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
        FacesContext context = getFacesContext();
        ELContext elContext = context.getELContext();
        ValueExpression updateBinding = getAssignToExpression();

        if (updateBinding != null && (!updateBinding.isReadOnly(elContext))) {
            String requestValue = context.getExternalContext().getRequestParameterMap().get(getName());

            Object convertedValue = requestValue;

            if (requestValue != null) {
                Class<?> type = updateBinding.getType(elContext);
                Converter converter = createConverter(context, type);

                if (null != converter) {
                    convertedValue = converter.getAsObject(context, this, requestValue);
                }
            }

            if (null != convertedValue) {
                updateBinding.setValue(elContext, convertedValue);
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.el.ValueExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.