Search in sources :

Example 1 with ParameterModel

use of org.apache.tapestry5.model.ParameterModel in project tapestry-5 by apache.

the class InternalComponentResourcesImplTest method render_informal_parameters_skips_formal_parameters.

@Test
public void render_informal_parameters_skips_formal_parameters() {
    ComponentPageElement element = mockComponentPageElement();
    Component component = mockComponent();
    Instantiator ins = mockInstantiator(component);
    MarkupWriter writer = mockMarkupWriter();
    ComponentModel model = mockComponentModel();
    ParameterModel pmodel = mockParameterModel();
    Binding binding = mockBinding();
    train_getModel(ins, model);
    train_getParameterModel(model, "fred", pmodel);
    replay();
    InternalComponentResources resources = new InternalComponentResourcesImpl(null, element, null, elementResources, null, null, ins, false);
    resources.bindParameter("fred", binding);
    resources.renderInformalParameters(writer);
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) InternalPropBinding(org.apache.tapestry5.internal.bindings.InternalPropBinding) ParameterModel(org.apache.tapestry5.model.ParameterModel) InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) ComponentModel(org.apache.tapestry5.model.ComponentModel) Instantiator(org.apache.tapestry5.internal.services.Instantiator) Component(org.apache.tapestry5.runtime.Component) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 2 with ParameterModel

use of org.apache.tapestry5.model.ParameterModel in project tapestry-5 by apache.

the class MutableComponentModelImplTest method add_new_parameter.

@Test
public void add_new_parameter() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    assertTrue(model.getParameterNames().isEmpty());
    String parameterName = "value";
    model.addParameter(parameterName, true, true, BindingConstants.PROP);
    ParameterModel pm = model.getParameterModel(parameterName);
    assertEquals(pm.getName(), parameterName);
    assertEquals(true, pm.isRequired());
    assertEquals(pm.getDefaultBindingPrefix(), BindingConstants.PROP);
    assertEquals(model.getDeclaredParameterNames(), Arrays.asList(parameterName));
    // Verify that the binding prefix is actually stored:
    model.addParameter("fred", true, true, "flint");
    // Checks that parameter names are case insensitive
    assertEquals(model.getParameterModel("Fred").getDefaultBindingPrefix(), "flint");
    verify();
}
Also used : ParameterModel(org.apache.tapestry5.model.ParameterModel) Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 3 with ParameterModel

use of org.apache.tapestry5.model.ParameterModel in project tapestry-5 by apache.

the class ComponentPageElementImpl method addUnboundParameterNames.

private void addUnboundParameterNames(String prefix, List<String> unbound, InternalComponentResources resource) {
    ComponentModel model = resource.getComponentModel();
    for (String name : model.getParameterNames()) {
        if (resource.isBound(name))
            continue;
        ParameterModel parameterModel = model.getParameterModel(name);
        if (parameterModel.isRequired()) {
            String fullName = prefix == null ? name : prefix + "." + name;
            unbound.add(fullName);
        }
    }
}
Also used : ParameterModel(org.apache.tapestry5.model.ParameterModel) ComponentModel(org.apache.tapestry5.model.ComponentModel)

Aggregations

ParameterModel (org.apache.tapestry5.model.ParameterModel)3 ComponentModel (org.apache.tapestry5.model.ComponentModel)2 Test (org.testng.annotations.Test)2 Binding (org.apache.tapestry5.Binding)1 MarkupWriter (org.apache.tapestry5.MarkupWriter)1 Resource (org.apache.tapestry5.commons.Resource)1 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)1 InternalPropBinding (org.apache.tapestry5.internal.bindings.InternalPropBinding)1 Instantiator (org.apache.tapestry5.internal.services.Instantiator)1 MutableComponentModel (org.apache.tapestry5.model.MutableComponentModel)1 Component (org.apache.tapestry5.runtime.Component)1 Logger (org.slf4j.Logger)1