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();
}
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();
}
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);
}
}
}
Aggregations