Package org.apache.tapestry

Examples of org.apache.tapestry.PropertyConduit


        Object target = container.getComponent();
        Class targetClass = target.getClass();

        try
        {
            PropertyConduit conduit = _source.create(targetClass, expression);

            String toString = String.format("PropBinding[%s %s(%s)]", description, container
                    .getCompleteId(), expression);

            return new PropBinding(target, conduit, toString, location);
View Full Code Here


        if (_properties.containsKey(propertyName))
            throw new RuntimeException(BeanEditorMessages.duplicatePropertyName(
                    _beanType,
                    propertyName));

        PropertyConduit conduit = createConduit(propertyName);

        return add(propertyName, conduit);
    }
View Full Code Here

            final boolean ascending)
    {
        if (sortModel == null)
            return;

        final PropertyConduit conduit = sortModel.getConduit();

        final Comparator valueComparator = new Comparator<Comparable>()
        {
            public int compare(Comparable o1, Comparable o2)
            {
                // Simplify comparison, and handle case where both are nulls.

                if (o1 == o2)
                    return 0;

                if (o2 == null)
                    return 1;

                if (o1 == null)
                    return -1;

                return o1.compareTo(o2);
            }
        };

        final Comparator rowComparator = new Comparator()
        {
            public int compare(Object row1, Object row2)
            {
                Comparable value1 = (Comparable) conduit.get(row1);
                Comparable value2 = (Comparable) conduit.get(row2);

                return valueComparator.compare(value1, value2);
            }
        };
View Full Code Here

        notNull(rootClass, "rootClass");
        notBlank(expression, "expression");

        MultiKey key = new MultiKey(rootClass, expression);

        PropertyConduit result = _cache.get(key);

        if (result == null)
        {
            result = build(rootClass, expression);
            _cache.put(key, result);
View Full Code Here

        Class effectiveClass = toEffectiveClass(rootClass);

        MultiKey key = new MultiKey(effectiveClass, expression);

        PropertyConduit result = _cache.get(key);

        if (result == null)
        {
            result = build(effectiveClass, expression);
            _cache.put(key, result);
View Full Code Here

        Object target = container.getComponent();
        Class targetClass = target.getClass();

        try
        {
            PropertyConduit conduit = _source.create(targetClass, expression);

            String toString = String.format("PropBinding[%s %s(%s)]", description, container
                    .getCompleteId(), expression);

            return new PropBinding(target, conduit, toString, location);
View Full Code Here

    }

    @Test
    public void question_dot_operator_for_object_type()
    {
        PropertyConduit normal = _source.create(CompositeBean.class, "simple.firstName");
        PropertyConduit smart = _source.create(CompositeBean.class, "simple?.firstName");

        CompositeBean bean = new CompositeBean();
        bean.setSimple(null);

        try
        {
            normal.get(bean);
            unreachable();
        }
        catch (NullPointerException ex)
        {
            // Expected.
        }

        assertNull(smart.get(bean));

        try
        {
            normal.set(bean, "Howard");
            unreachable();
        }
        catch (NullPointerException ex)
        {
            // Expected.
        }

        // This will be a no-op due to the null property in the expression

        smart.set(bean, "Howard");
    }
View Full Code Here

        assertTrue(simple instanceof Serializable);

        simple.setFirstName("Howard");

        PropertyConduit conduit = _source.create(proxyClass, "firstName");

        assertEquals(conduit.get(simple), "Howard");
    }
View Full Code Here

        StringHolder stringHolder = new StringHolder();
        stringHolder.put(string);
        StringHolderBean bean = new StringHolderBean();
        bean.setValue(stringHolder);

        PropertyConduit conduit = _source.create(StringHolderBean.class, "value.get()");

        assertSame(conduit.get(bean), string);

        assertSame(conduit.getPropertyType(), String.class);
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public void prepare(int startIndex, int endIndex, PropertyModel sortModel, final boolean ascending)
    {
        if (sortModel == null) return;

        final PropertyConduit conduit = sortModel.getConduit();

        final Comparator valueComparator = new Comparator<Comparable>()
        {
            public int compare(Comparable o1, Comparable o2)
            {
                // Simplify comparison, and handle case where both are nulls.

                if (o1 == o2) return 0;

                if (o2 == null) return 1;

                if (o1 == null) return -1;

                return o1.compareTo(o2);
            }
        };

        final Comparator rowComparator = new Comparator()
        {
            public int compare(Object row1, Object row2)
            {
                Comparable value1 = (Comparable) conduit.get(row1);
                Comparable value2 = (Comparable) conduit.get(row2);

                return valueComparator.compare(value1, value2);
            }
        };
View Full Code Here

TOP

Related Classes of org.apache.tapestry.PropertyConduit

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.