use of org.apache.tapestry5.internal.SelectModelImpl in project tapestry-5 by apache.
the class SelectTest method disabled_option.
@Test
public void disabled_option() throws Exception {
ValidationTracker tracker = mockValidationTracker();
// Extra cast needed for Sun compiler, not Eclipse compiler.
List<OptionModel> options = Arrays.asList((OptionModel) new OptionModelImpl("Fred", "fred") {
@Override
public boolean isDisabled() {
return true;
}
@Override
public Map<String, String> getAttributes() {
return Collections.singletonMap("class", "pixie");
}
});
Select select = new Select();
train_getInput(tracker, select, null);
replay();
select.setModel(new SelectModelImpl(null, options));
select.setValueEncoder(new StringValueEncoder());
select.setValue("barney");
select.setValidationTracker(tracker);
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
writer.element("select");
select.options(writer);
writer.end();
assertEquals(writer.toString(), read("disabled_option.txt"));
verify();
}
use of org.apache.tapestry5.internal.SelectModelImpl in project tapestry-5 by apache.
the class ActivationRequestParameterDemo method getClickCountModel.
public SelectModel getClickCountModel() {
OptionModel one = new OptionModelImpl("one", 1);
OptionModel two = new OptionModelImpl("two", 2);
OptionModel three = new OptionModelImpl("three", 3);
return new SelectModelImpl(one, two, three);
}
use of org.apache.tapestry5.internal.SelectModelImpl in project tapestry-5 by apache.
the class SelectModelFactoryImpl method createSelectModel.
private SelectModel createSelectModel(List<?> objects, ValueLabelProvider<Object> labelProvider) {
final List<OptionModel> options = CollectionFactory.newList();
for (Object object : objects) {
String label = labelProvider.getLabel(object);
options.add(new OptionModelImpl(label, object));
}
return new SelectModelImpl(null, options);
}
use of org.apache.tapestry5.internal.SelectModelImpl in project tapestry-5 by apache.
the class SelectTest method empty_model.
@Test
public void empty_model() {
ValidationTracker tracker = mockValidationTracker();
Select select = new Select();
train_getInput(tracker, select, null);
replay();
select.setModel(new SelectModelImpl(null, null));
select.setValidationTracker(tracker);
select.options(null);
verify();
}
use of org.apache.tapestry5.internal.SelectModelImpl in project tapestry-5 by apache.
the class SelectTest method current_selection_from_validation_tracker.
@Test
public void current_selection_from_validation_tracker() throws Exception {
ValidationTracker tracker = mockValidationTracker();
List<OptionModel> options = TapestryInternalUtils.toOptionModels("fred=Fred Flintstone,barney=Barney Rubble");
Select select = new Select();
train_getInput(tracker, select, "fred");
replay();
select.setModel(new SelectModelImpl(null, options));
select.setValueEncoder(new StringValueEncoder());
select.setValue("barney");
select.setValidationTracker(tracker);
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
writer.element("select");
select.options(writer);
writer.end();
// fred will be selected, not barney, because the validation tracker
// takes precendence.
assertEquals(writer.toString(), read("current_selection_from_validation_tracker.txt"));
verify();
}
Aggregations