use of org.apache.tapestry5.internal.OptionModelImpl in project tapestry-5 by apache.
the class SelectTest method option_attributes.
@Test
public void option_attributes() 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 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("option_attributes.txt"));
verify();
}
use of org.apache.tapestry5.internal.OptionModelImpl 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.OptionModelImpl 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.OptionModelImpl in project tapestry-5 by apache.
the class OptionModelImplTest method basics.
@Test
public void basics() {
OptionModel model = new OptionModelImpl("Label", this);
assertEquals(model.getLabel(), "Label");
assertFalse(model.isDisabled());
assertSame(model.getValue(), this);
assertNull(model.getAttributes());
model = new OptionModelImpl("Fred", "fred");
assertEquals(model.toString(), "OptionModel[Fred fred]");
}
use of org.apache.tapestry5.internal.OptionModelImpl 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);
}
Aggregations