Search in sources :

Example 6 with OptionGroupModelImpl

use of org.apache.tapestry5.internal.OptionGroupModelImpl in project tapestry-5 by apache.

the class SelectTest method option_groups_precede_ungroup_options.

@Test
public void option_groups_precede_ungroup_options() throws Exception {
    ValidationTracker tracker = mockValidationTracker();
    OptionGroupModel husbands = new OptionGroupModelImpl("Husbands", false, TapestryInternalUtils.toOptionModels("Fred,Barney"));
    Select select = new Select();
    train_getInput(tracker, select, null);
    replay();
    select.setModel(new SelectModelImpl(Collections.singletonList(husbands), TapestryInternalUtils.toOptionModels("Wilma,Betty")));
    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_precede_ungroup_options.txt"));
    verify();
}
Also used : MarkupWriterImpl(org.apache.tapestry5.internal.services.MarkupWriterImpl) SelectModelImpl(org.apache.tapestry5.internal.SelectModelImpl) OptionGroupModelImpl(org.apache.tapestry5.internal.OptionGroupModelImpl) StringValueEncoder(org.apache.tapestry5.internal.services.StringValueEncoder) XMLMarkupModel(org.apache.tapestry5.dom.XMLMarkupModel) Test(org.testng.annotations.Test)

Example 7 with OptionGroupModelImpl

use of org.apache.tapestry5.internal.OptionGroupModelImpl in project tapestry-5 by apache.

the class SelectTest method option_group_attributes.

@Test
public void option_group_attributes() throws Exception {
    ValidationTracker tracker = mockValidationTracker();
    Map<String, String> attributes = Collections.singletonMap("class", "pixie");
    OptionGroupModel husbands = new OptionGroupModelImpl("Husbands", false, TapestryInternalUtils.toOptionModels("Fred,Barney"), attributes);
    Select select = new Select();
    train_getInput(tracker, select, null);
    replay();
    select.setModel(new SelectModelImpl(Collections.singletonList(husbands), 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_group_attributes.txt"));
    verify();
}
Also used : MarkupWriterImpl(org.apache.tapestry5.internal.services.MarkupWriterImpl) SelectModelImpl(org.apache.tapestry5.internal.SelectModelImpl) OptionGroupModelImpl(org.apache.tapestry5.internal.OptionGroupModelImpl) StringValueEncoder(org.apache.tapestry5.internal.services.StringValueEncoder) XMLMarkupModel(org.apache.tapestry5.dom.XMLMarkupModel) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)6 OptionGroupModel (org.apache.tapestry5.OptionGroupModel)4 OptionModel (org.apache.tapestry5.OptionModel)4 OptionGroupModelImpl (org.apache.tapestry5.internal.OptionGroupModelImpl)4 XMLMarkupModel (org.apache.tapestry5.dom.XMLMarkupModel)3 SelectModelImpl (org.apache.tapestry5.internal.SelectModelImpl)3 MarkupWriterImpl (org.apache.tapestry5.internal.services.MarkupWriterImpl)3 StringValueEncoder (org.apache.tapestry5.internal.services.StringValueEncoder)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entity (org.apache.tapestry5.integration.app1.data.Entity)1 OptionModelImpl (org.apache.tapestry5.internal.OptionModelImpl)1 AbstractSelectModel (org.apache.tapestry5.util.AbstractSelectModel)1