Package org.apache.tapestry.beaneditor

Examples of org.apache.tapestry.beaneditor.PropertyModel


    public BeanModel remove(String... propertyNames)
    {
        for (String propertyName : propertyNames)
        {
            PropertyModel model = _properties.get(propertyName);

            if (model == null) continue;

            // De-referencing from the model is needed because the name provided may not be a
            // case-exact match, so we get the normalized or canonical name from the model because
            // that's the one in _propertyNames.

            _propertyNames.remove(model.getPropertyName());

            _properties.remove(propertyName);
        }

        return this;
View Full Code Here


        List<String> remainingPropertyNames = newList(_propertyNames);
        List<String> reorderedPropertyNames = newList();

        for (String name : propertyName)
        {
            PropertyModel model = get(name);

            // Get the canonical form (which may differ from name in terms of case)
            String canonical = model.getPropertyName();

            reorderedPropertyNames.add(canonical);

            remainingPropertyNames.remove(canonical);
        }
View Full Code Here

        assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));

        assertEquals(model.toString(),
                     "BeanModel[org.apache.tapestry.internal.services.SimpleBean properties:firstName, lastName, age]");

        PropertyModel age = model.get("age");

        assertEquals(age.getLabel(), "Age");
        assertSame(age.getPropertyType(), int.class);
        assertEquals(age.getDataType(), "text");
        assertEquals(age.getWidth(), 2);

        PropertyModel firstName = model.get("firstName");

        assertEquals(firstName.getLabel(), "First Name");
        assertEquals(firstName.getPropertyType(), String.class);
        assertEquals(firstName.getDataType(), "text");
        assertEquals(firstName.getWidth(), 0);

        assertEquals(model.get("lastName").getLabel(), "Last Name");

        PropertyConduit conduit = model.get("lastName").getConduit();
View Full Code Here

        assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));

        // Note the use of case insensitivity here.

        PropertyModel property = model.add(RelativePosition.BEFORE, "lastname", "middleInitial", conduit);

        assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "middleInitial", "lastName", "age"));

        assertEquals(property.getPropertyName(), "middleInitial");
        assertSame(property.getConduit(), conduit);
        assertSame(property.getPropertyType(), propertyType);

        verify();
    }
View Full Code Here

        assertEquals(model.getPropertyNames(), Arrays.asList("lastName", "age"));

        // Note the use of case insensitivity here.

        PropertyModel property = model.add(RelativePosition.BEFORE, "lastname", "firstName");

        assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));

        assertEquals(property.getPropertyName(), "firstName");
        assertSame(property.getPropertyType(), String.class);

        verify();
    }
View Full Code Here

        BeanModel model = _source.create(SimpleBean.class, true, resources);

        assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "lastName", "age"));

        PropertyModel property = model.add(RelativePosition.AFTER, "firstname", "middleInitial", conduit);

        assertEquals(model.getPropertyNames(), Arrays.asList("firstName", "middleInitial", "lastName", "age"));

        assertEquals(property.getPropertyName(), "middleInitial");
        assertSame(property.getConduit(), conduit);
        assertSame(property.getPropertyType(), propertyType);

        verify();
    }
View Full Code Here

        BeanModel model = _source.create(StringArrayBean.class, true, resources);

        // There's not editor for string arrays yet, so it won't show up normally.

        PropertyModel propertyModel = model.add("array");

        assertSame(propertyModel.getPropertyType(), String[].class);

        String[] value = {"foo", "bar"};

        StringArrayBean bean = new StringArrayBean();

        PropertyConduit conduit = propertyModel.getConduit();

        conduit.set(bean, value);

        assertSame(bean.getArray(), value);
View Full Code Here

        assertEquals(model.getPropertyNames(), Collections.emptyList());

        // There's not editor for string arrays yet, so it won't show up normally.

        PropertyModel firstName = model.add("simple.firstName");

        assertEquals(firstName.getLabel(), "First Name");

        PropertyModel age = model.add("simple.age");
        assertEquals(age.getLabel(), "Years of Age");

        CompositeBean bean = new CompositeBean();

        firstName.getConduit().set(bean, "Fred");
        age.getConduit().set(bean, "97");

        assertEquals(bean.getSimple().getFirstName(), "Fred");
        assertEquals(bean.getSimple().getAge(), 97);

        bean.getSimple().setAge(24);

        assertEquals(age.getConduit().get(bean), new Integer(24));

        verify();
    }
View Full Code Here

        replay();

        BeanModel model = _source.create(SimpleBean.class, true, resources);

        PropertyModel property = model.add("placeholder", null);

        assertFalse(property.isSortable());
        assertSame(property.getPropertyType(), Object.class);
        assertEquals(property.getLabel(), "Placeholder");

        verify();
    }
View Full Code Here

public class PropertyEditorTest extends TapestryTestCase
{
    @Test
    public void no_editor_block_available()
    {
        PropertyModel model = mockPropertyModel();
        ComponentResources overrides = mockComponentResources();
        ComponentResources resources = mockComponentResources();
        BeanBlockSource source = newMock(BeanBlockSource.class);
        RuntimeException exception = new RuntimeException("Simulated failure.");
        Messages messages = mockMessages();
        Location l = mockLocation();

        String propertyId = "foo";
        String dataType = "unk";
        String propertyName = "fooProp";
        Object object = "[OBJECT]";
        String formattedMessage = "formatted-message";

        expect(model.getId()).andReturn(propertyId);

        expect(overrides.getBlockParameter(propertyId)).andReturn(null);

        expect(model.getDataType()).andReturn(dataType);

        expect(source.getEditBlock(dataType)).andThrow(exception);
        expect(model.getPropertyName()).andReturn(propertyName);

        train_getLocation(resources, l);

        expect(messages.format("block-error", propertyName, dataType, object, exception))
                .andReturn(formattedMessage);
View Full Code Here

TOP

Related Classes of org.apache.tapestry.beaneditor.PropertyModel

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.