use of org.apache.tapestry5.OptionGroupModel in project tapestry-5 by apache.
the class SelectTest method option_groups.
@Test
public void option_groups() throws Exception {
ValidationTracker tracker = mockValidationTracker();
OptionGroupModel husbands = new OptionGroupModelImpl("Husbands", false, TapestryInternalUtils.toOptionModels("Fred,Barney"));
OptionGroupModel wives = new OptionGroupModelImpl("Wives", true, TapestryInternalUtils.toOptionModels("Wilma,Betty"));
List<OptionGroupModel> groupModels = CollectionFactory.newList(husbands, wives);
Select select = new Select();
train_getInput(tracker, select, null);
replay();
select.setModel(new SelectModelImpl(groupModels, null));
select.setValueEncoder(new StringValueEncoder());
select.setValue("Fred");
select.setValidationTracker(tracker);
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
writer.element("select");
select.options(writer);
writer.end();
assertEquals(writer.toString(), read("option_groups.txt"));
verify();
}
use of org.apache.tapestry5.OptionGroupModel in project tapestry-5 by apache.
the class AbstractSelectModel method visit.
public final void visit(SelectModelVisitor visitor) {
List<OptionGroupModel> groups = getOptionGroups();
if (groups != null) {
for (OptionGroupModel groupModel : groups) {
visitor.beginOptionGroup(groupModel);
visitOptions(groupModel.getOptions(), visitor);
visitor.endOptionGroup(groupModel);
}
}
visitOptions(getOptions(), visitor);
}
use of org.apache.tapestry5.OptionGroupModel in project tapestry-5 by apache.
the class OptionGroupModelImplTest method strings_contructor_builds_map.
@Test
public void strings_contructor_builds_map() {
List<OptionModel> options = Collections.emptyList();
OptionGroupModel group = new OptionGroupModelImpl("Label", true, options, "fred", "flintstone", "barney", "rubble");
Map<String, String> attributes = group.getAttributes();
assertEquals(attributes.size(), 2);
assertEquals(attributes.get("fred"), "flintstone");
assertEquals(attributes.get("barney"), "rubble");
}
use of org.apache.tapestry5.OptionGroupModel in project tapestry-5 by apache.
the class OptionGroupModelImplTest method map_contructor_retains_map.
@Test
public void map_contructor_retains_map() {
List<OptionModel> options = Collections.emptyList();
Map<String, String> attributes = Collections.emptyMap();
OptionGroupModel group = new OptionGroupModelImpl("Label", true, options, attributes);
assertSame(group.getAttributes(), attributes);
}
use of org.apache.tapestry5.OptionGroupModel in project tapestry-5 by apache.
the class OptionGroupModelImplTest method basics.
@Test
public void basics() {
List<OptionModel> options = Collections.emptyList();
OptionGroupModel group = new OptionGroupModelImpl("Label", true, options);
assertEquals(group.toString(), "OptionGroupModel[Label]");
assertTrue(group.isDisabled());
assertNull(group.getAttributes());
assertSame(group.getOptions(), options);
}
Aggregations