Search in sources :

Example 6 with PropertyModel

use of org.apache.tapestry5.beanmodel.PropertyModel in project tapestry-5 by apache.

the class AbstractBeanModelSourceImplTest method get_added_property_by_name.

@Test
public void get_added_property_by_name() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    PropertyModel pm = model.addEmpty("shrub.foo()");
    assertSame(model.get("Shrub.Foo()"), pm);
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) PropertyModel(org.apache.tapestry5.beanmodel.PropertyModel) Test(org.testng.annotations.Test)

Example 7 with PropertyModel

use of org.apache.tapestry5.beanmodel.PropertyModel in project tapestry-5 by apache.

the class AbstractBeanModelSourceImplTest method add_before_using_default_conduit.

@Test
public void add_before_using_default_conduit() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    model.exclude("firstname");
    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();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) PropertyModel(org.apache.tapestry5.beanmodel.PropertyModel) Test(org.testng.annotations.Test)

Example 8 with PropertyModel

use of org.apache.tapestry5.beanmodel.PropertyModel in project tapestry-5 by apache.

the class AbstractBeanModelSourceImplTest method get_added_property_by_name.

@Test
public void get_added_property_by_name() {
    Messages messages = mockMessages();
    stub_contains(messages, false);
    replay();
    BeanModel model = source.create(SimpleBean.class, true, messages);
    PropertyModel pm = model.addEmpty("shrub.foo()");
    assertSame(model.get("Shrub.Foo()"), pm);
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) BeanModel(org.apache.tapestry5.beanmodel.BeanModel) PropertyModel(org.apache.tapestry5.beanmodel.PropertyModel) Test(org.testng.annotations.Test)

Example 9 with PropertyModel

use of org.apache.tapestry5.beanmodel.PropertyModel in project tapestry-5 by apache.

the class BeanModelImpl method add.

public PropertyModel add(String propertyName, PropertyConduit conduit) {
    validateNewPropertyName(propertyName);
    PropertyModel propertyModel = new PropertyModelImpl(this, propertyName, conduit, messages);
    properties.put(propertyName, propertyModel);
    // Remember the order in which the properties were added.
    propertyNames.add(propertyName);
    return propertyModel;
}
Also used : PropertyModel(org.apache.tapestry5.beanmodel.PropertyModel)

Example 10 with PropertyModel

use of org.apache.tapestry5.beanmodel.PropertyModel in project tapestry-5 by apache.

the class BeanModelImpl method add.

public PropertyModel add(RelativePosition position, String existingPropertyName, String propertyName, PropertyConduit conduit) {
    assert position != null;
    validateNewPropertyName(propertyName);
    // Locate the existing one.
    PropertyModel existing = get(existingPropertyName);
    // Use the case normalized property name.
    int pos = propertyNames.indexOf(existing.getPropertyName());
    PropertyModel newModel = new PropertyModelImpl(this, propertyName, conduit, messages);
    properties.put(propertyName, newModel);
    int offset = position == RelativePosition.AFTER ? 1 : 0;
    propertyNames.add(pos + offset, propertyName);
    return newModel;
}
Also used : PropertyModel(org.apache.tapestry5.beanmodel.PropertyModel)

Aggregations

PropertyModel (org.apache.tapestry5.beanmodel.PropertyModel)29 Test (org.testng.annotations.Test)23 BeanModel (org.apache.tapestry5.beanmodel.BeanModel)21 Messages (org.apache.tapestry5.commons.Messages)19 PropertyConduit (org.apache.tapestry5.beanmodel.PropertyConduit)9 BeforeClass (org.testng.annotations.BeforeClass)4 ComponentResources (org.apache.tapestry5.ComponentResources)2 Location (org.apache.tapestry5.commons.Location)2 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)2 Annotation (java.lang.annotation.Annotation)1 PropertyOverrides (org.apache.tapestry5.PropertyOverrides)1 SortConstraint (org.apache.tapestry5.grid.SortConstraint)1 BeanValidationContext (org.apache.tapestry5.internal.BeanValidationContext)1 BeanBlockSource (org.apache.tapestry5.services.BeanBlockSource)1 PropertyEditContext (org.apache.tapestry5.services.PropertyEditContext)1