use of org.apache.tapestry5.MarkupWriter 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.MarkupWriter in project tapestry-5 by apache.
the class SelectTest method just_options_with_blank_label_enabled.
@Test
public void just_options_with_blank_label_enabled() throws Exception {
ValidationTracker tracker = mockValidationTracker();
List<OptionModel> options = TapestryInternalUtils.toOptionModels("fred=Fred Flintstone,barney=Barney Rubble");
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);
select.setBlankOption(BlankOption.ALWAYS, "Make a selection");
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
writer.element("select");
select.options(writer);
writer.end();
assertEquals(writer.toString(), read("blank_label.txt"));
verify();
}
use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.
the class SelectTest method output_with_raw_enabled.
@Test
public void output_with_raw_enabled() throws Exception {
ValidationTracker tracker = mockValidationTracker();
List<OptionModel> options = TapestryInternalUtils.toOptionModels("bold=<b>Bold</b>,italic=<i>Italic</i>");
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);
select.setRaw(true);
MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel());
writer.element("select");
select.options(writer);
writer.end();
assertEquals(writer.toString(), read("output_with_raw_enabled.txt"));
verify();
}
use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.
the class AnyTest method render_simple.
@Test
public void render_simple() {
ComponentResources resources = mockComponentResources();
JavaScriptSupport support = mockJavaScriptSupport();
MarkupWriter writer = new MarkupWriterImpl(new DefaultMarkupModel());
resources.renderInformalParameters(writer);
replay();
Any component = new Any();
component.inject(support, resources, "span", "foo");
component.beginRender(writer);
writer.write("content");
component.afterRender(writer);
assertEquals(writer.toString(), "<span>content</span>");
verify();
}
use of org.apache.tapestry5.MarkupWriter in project tapestry-5 by apache.
the class AnyTest method render_with_id.
@Test
public void render_with_id() {
ComponentResources resources = mockComponentResources();
JavaScriptSupport support = mockJavaScriptSupport();
MarkupWriter writer = new MarkupWriterImpl(new DefaultMarkupModel());
resources.renderInformalParameters(writer);
String clientId = "bar";
String uniqueId = "bar_0";
expect(support.allocateClientId(clientId)).andReturn(uniqueId);
replay();
Any component = new Any();
component.inject(support, resources, "div", clientId);
component.beginRender(writer);
writer.write("content");
component.afterRender(writer);
assertEquals(writer.toString(), "<div>content</div>");
assertEquals(component.getClientId(), uniqueId);
assertEquals(writer.toString(), "<div id=\"bar_0\">content</div>");
assertEquals(component.getClientId(), uniqueId);
verify();
}
Aggregations