use of org.apache.wicket.markup.IMarkupResourceStreamProvider in project wicket by apache.
the class EnclosureTest method testAtrribute.
/**
* https://issues.apache.org/jira/browse/WICKET-3842
*/
@Test
public void testAtrribute() {
/**
* Page for the test
*/
class TestPage extends WebPage implements IMarkupResourceStreamProvider {
private static final long serialVersionUID = 1L;
public TestPage() {
final Label l = new Label("msg", "$label$");
add(l);
add(new Link<Void>("b") {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
l.setVisible(!l.isVisible());
}
});
}
@Override
public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) {
return new StringResourceStream("<html><body><div wicket:enclosure='msg'><span wicket:id='msg'></span></div><input type='button' value='Toggle' wicket:id='b'/></body></html>");
}
}
tester.startPage(new TestPage());
assertTrue(tester.getLastResponseAsString().contains("$label$"));
// toggle visibility of enclosure to false
tester.clickLink("b");
assertFalse(tester.getLastResponseAsString().contains("$label$"));
// toggle visibility of enclosure to back to true
tester.clickLink("b");
assertTrue(tester.getLastResponseAsString().contains("$label$"));
}
use of org.apache.wicket.markup.IMarkupResourceStreamProvider in project wicket by apache.
the class FormTesterSubmitLinkTest method radioComponentValueEncoding.
@Test
public void radioComponentValueEncoding() {
class TestPage extends WebPage implements IMarkupResourceStreamProvider {
private static final long serialVersionUID = 1L;
private String value;
private boolean submitted;
public TestPage() {
Form<Void> form = new Form<Void>("form");
add(form);
RadioGroup<String> group = new RadioGroup<String>("group", new PropertyModel<String>(this, "value"));
form.add(group);
value = "a";
group.add(new Radio<String>("a", Model.of("a")));
group.add(new Radio<String>("b", Model.of("b")));
form.add(new AjaxSubmitLink("submit") {
@Override
protected void onSubmit(AjaxRequestTarget target) {
submitted = true;
}
@Override
protected void onError(AjaxRequestTarget target) {
}
});
}
@Override
public IResourceStream getMarkupResourceStream(MarkupContainer container, Class<?> containerClass) {
return new StringResourceStream("<html><body><form wicket:id='form'><div wicket:id='group'><input type='radio' wicket:id='a'/><input type='radio' wicket:id='b'/></div><input wicket:id='submit' type='submit'/></form></body></html>");
}
}
TestPage page = new TestPage();
WicketTester tester = new WicketTester();
tester.startPage(page);
// clicking an ajax submit link will force the form to be ajax-serialized, current values of
// form components copied into request. this will check that the value of radio is correctly
// serialized.
tester.clickLink("form:submit");
assertTrue(page.submitted);
assertEquals("a", page.value);
}
Aggregations