Package org.apache.myfaces.extensions.validator.core.el

Examples of org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression


    }

    @Test
    public void testFaceletsCustomComponentSyntaxReplaceProperty() throws Exception
    {
        ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{entity[fieldName]}");

        valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "newFieldName");

        //TODO restore original syntax
        Assert.assertEquals("#{entity.newFieldName}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{entity}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("newFieldName", valueBindingExpression.getProperty());
    }
View Full Code Here


    }

    @Test
    public void testComplexMapSyntax() throws Exception
    {
        ValueBindingExpression valueBindingExpression
                = new ValueBindingExpression("#{bean1[bean2[bean3['key1']]].property1}");

        //TODO
        //assertEquals("#{bean1[bean2[bean3['key1']]].property1}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("property1", valueBindingExpression.getProperty());
    }
View Full Code Here

        ELHelper elHelper = ExtValUtils.getELHelper();
        for(String valueBindingExpression : valueBindingExpressions)
        {
            if(Boolean.TRUE.equals(elHelper.getValueOfExpression(
                facesContext, new ValueBindingExpression(valueBindingExpression))))
            {
                metaDataEntry.setProperty(PropertyInformationKeys.SKIP_VALIDATION, true);
                break;
            }
        }
View Full Code Here

                                                                    String targetExpression)
    {
        Object baseObject;
        if (getELHelper().isELTermWellFormed(targetExpression))
        {
            ValueBindingExpression vbe = new ValueBindingExpression(targetExpression);

            String expression = vbe.getExpressionString();
            baseObject = getELHelper().getValueOfExpression(FacesContext.getCurrentInstance(), vbe.getBaseExpression());
            return new PropertyDetails(
                    expression.substring(2, expression.length() - 1), baseObject, vbe.getProperty());
        }

        PropertyDetails original = metaDataEntry.getProperty(
                PropertyInformationKeys.PROPERTY_DETAILS, PropertyDetails.class);
View Full Code Here

{

    @Test
    public void testStandardSyntax() throws Exception
    {
        ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{bean1.property1}");

        Assert.assertEquals("#{bean1.property1}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("property1", valueBindingExpression.getProperty());

        valueBindingExpression = new ValueBindingExpression("#{bean1['property1']}");

        Assert.assertEquals("#{bean1['property1']}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("property1", valueBindingExpression.getProperty());

        valueBindingExpression = new ValueBindingExpression("#{bean1['bean2'].property1}");

        Assert.assertEquals("#{bean1['bean2'].property1}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{bean1['bean2']}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getBaseExpression().getExpressionString());
        Assert.assertEquals("property1", valueBindingExpression.getProperty());
    }
View Full Code Here

    }

    @Test
    public void testStandardSyntaxReplaceProperty() throws Exception
    {
        ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{bean1.property1}");

        valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "property2");

        Assert.assertEquals("#{bean1.property2}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("property2", valueBindingExpression.getProperty());

        valueBindingExpression = new ValueBindingExpression("#{bean1['property1']}");

        valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "property2");

        //TODO restore original syntax
        Assert.assertEquals("#{bean1.property2}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("property2", valueBindingExpression.getProperty());

        valueBindingExpression = new ValueBindingExpression("#{bean1['bean2'].property1}");

        valueBindingExpression = ValueBindingExpression.replaceProperty(valueBindingExpression, "property2");

        Assert.assertEquals("#{bean1['bean2'].property2}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{bean1['bean2']}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("#{bean1}", valueBindingExpression.getBaseExpression().getBaseExpression().getExpressionString());
        Assert.assertEquals("property2", valueBindingExpression.getProperty());
    }
View Full Code Here

    }

    @Test
    public void testStandardSyntaxAddProperty() throws Exception
    {
        ValueBindingExpression valueBindingExpression = new ValueBindingExpression("#{bean1.bean2}");

        valueBindingExpression = ValueBindingExpression.addProperty(valueBindingExpression, "property1");

        Assert.assertEquals("#{bean1.bean2.property1}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{bean1.bean2}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("property1", valueBindingExpression.getProperty());

        valueBindingExpression = new ValueBindingExpression("#{bean1['bean2']}");

        valueBindingExpression = ValueBindingExpression.addProperty(valueBindingExpression, "property1");

        Assert.assertEquals("#{bean1['bean2'].property1}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{bean1['bean2']}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("property1", valueBindingExpression.getProperty());

        valueBindingExpression = new ValueBindingExpression("#{bean1['bean2'].bean3}");

        valueBindingExpression = ValueBindingExpression.addProperty(valueBindingExpression, "property1");

        Assert.assertEquals("#{bean1['bean2'].bean3.property1}", valueBindingExpression.getExpressionString());
        Assert.assertEquals("#{bean1['bean2'].bean3}", valueBindingExpression.getBaseExpression().getExpressionString());
        Assert.assertEquals("#{bean1['bean2']}",
                valueBindingExpression.getBaseExpression().getBaseExpression().getExpressionString());
        Assert.assertEquals("property1", valueBindingExpression.getProperty());
    }
View Full Code Here

        String expression;
        Object value;
        while (matcher.find())
        {
            expression = matcher.group();
            value = getELHelper().getValueOfExpression(facesContext, new ValueBindingExpression(expression));

            if(value == null)
            {
                value = "null";
            }
View Full Code Here

    {
        if (ExtValUtils.getELHelper().isELTermWellFormed(validationTarget) &&
            ExtValUtils.getELHelper().isELTermValid(FacesContext.getCurrentInstance(), validationTarget))
        {
            tryToValidateValueBinding(crossValidationStorageEntry,
                new ValueBindingExpression(validationTarget), crossValidationStorage, compareStrategy);
            return true;
        }
        return false;
    }
View Full Code Here

    protected String createTargetKey(CrossValidationStorageEntry crossValidationStorageEntry, String targetKey)
    {
        //no real value binding expression
        //ValueBindingExpression just hepls to replace the property of the key
        //here only dot-notation is allowed -> no problem
        ValueBindingExpression baseExpression =
            new ValueBindingExpression("#{" + crossValidationStorageEntry.getMetaDataEntry()
                .getProperty(PropertyInformationKeys.PROPERTY_DETAILS,
                    PropertyDetails.class).getKey() + "}");

        String result = ValueBindingExpression.replaceOrAddProperty(baseExpression, targetKey)
            .getExpressionString();
View Full Code Here

TOP

Related Classes of org.apache.myfaces.extensions.validator.core.el.ValueBindingExpression

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.