use of org.apache.wicket.markup.html.border.Border in project wicket by apache.
the class LocalizedImageResource method loadStaticImage.
/**
* Tries to load static image at the given path and throws an exception if the image cannot be
* located.
*
* @param path
* The path to the image
* @throws WicketRuntimeException
* Thrown if the image cannot be located
*/
private void loadStaticImage(final String path) {
MarkupContainer parent = component.findParentWithAssociatedMarkup();
if (parent instanceof Border) {
parent = parent.getParent();
}
final Class<?> scope = parent.getClass();
resourceReference = new PackageResourceReference(scope, path, locale, style, variation);
bind();
}
use of org.apache.wicket.markup.html.border.Border in project wicket by apache.
the class MarkupFragmentTest method border2.
/**
* @throws Exception
*/
@Test
public void border2() throws Exception {
Page page = new MyBorderPage();
Border border = (Border) page.get("border2");
// Get the associated markup file
IMarkupFragment markup = border.getAssociatedMarkup();
compareMarkupWithFile(markup, "MyBorder2_ExpectedResult.html", MyPage.class);
// getMarkup() returns the "calling" tags
markup = border.getMarkup();
compareMarkupWithString(markup, "<span wicket:id=\"border2\">test</span>");
// getMarkup(null) returns the markup which is used to find a child component
markup = border.getMarkup(null);
compareMarkupWithString(markup, "<wicket:border> 111 <wicket:body>333</wicket:body> 222</wicket:border>");
assertNull(border.getBodyContainer().getAssociatedMarkup());
// See explanation in BaseBorder.BorderBodyContainer.getMarkup()
border.dequeue();
markup = border.getBodyContainer().getParent().getMarkup(border.getBodyContainer());
compareMarkupWithString(markup, "<wicket:body>333</wicket:body>");
markup = border.getBodyContainer().getMarkup();
compareMarkupWithString(markup, "<wicket:body>333</wicket:body>");
// getMarkup(null) returns the markup which is used to find a child component
markup = border.getBodyContainer().getMarkup(null);
compareMarkupWithString(markup, "<span wicket:id=\"border2\">test</span>");
}
use of org.apache.wicket.markup.html.border.Border in project wicket by apache.
the class SimplePageTest method renderHomePage_2.
/**
* @throws Exception
*/
@Test
public void renderHomePage_2() throws Exception {
executeTest(SimplePage.class, "SimplePageExpectedResult.html");
String document = tester.getLastResponseAsString();
Label label = (Label) tester.getLastRenderedPage().get("myLabel");
assertNotNull(label);
assertTrue(document.contains("<span wicket:id=\"myLabel\">Test Label</span>"));
Panel panel = (Panel) tester.getLastRenderedPage().get("myPanel");
assertNotNull(panel);
assertTrue(document.contains("<wicket:panel>Inside the panel<span wicket:id=\"label\">mein Label</span></wicket:panel>"));
label = (Label) tester.getLastRenderedPage().get("myPanel:label");
assertNotNull(label);
assertFalse("".equals(document));
assertTrue(document.contains("<span wicket:id=\"label\">mein Label</span>"));
Border border = (Border) tester.getLastRenderedPage().get("myBorder");
assertNotNull(border);
assertFalse("".equals(document));
assertTrue(document.contains("<wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border>"));
border = (Border) tester.getLastRenderedPage().get("myBorder2");
assertNotNull(border);
assertFalse("".equals(document));
assertTrue(document.contains("<span wicket:id=\"myBorder2\" testAttr=\"myValue\"><wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border></span>"));
// do the same test twice. Igor reported a problem with that, so we have to test it.
border = (Border) tester.getLastRenderedPage().get("myBorder2");
assertNotNull(border);
assertFalse("".equals(document));
assertTrue(document.contains("<span wicket:id=\"myBorder2\" testAttr=\"myValue\"><wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border></span>"));
WebMarkupContainer container = (WebMarkupContainer) tester.getLastRenderedPage().get("test");
assertNotNull(container);
assertFalse("".equals(document));
assertTrue(document.contains("body<span wicket:id=\"myLabel2\">Test Label2</span>"));
label = (Label) tester.getLastRenderedPage().get("test:myLabel2");
assertNotNull(label);
assertFalse("".equals(document));
assertTrue(document.contains("<span wicket:id=\"myLabel2\">Test Label2</span>"));
}
use of org.apache.wicket.markup.html.border.Border in project wicket by apache.
the class SimplePageTest method renderHomePage_2b.
/**
* @throws Exception
*/
@Test
public void renderHomePage_2b() throws Exception {
// Render the component without having rendered the page previously
SimplePage page = new SimplePage();
Label label = (Label) page.get("myLabel");
assertNotNull(label);
ValueMap attr = label.getMarkupAttributes();
assertNotNull(attr);
assertEquals("myLabel", attr.getString("wicket:id"));
Panel panel = (Panel) page.get("myPanel");
assertNotNull(panel);
attr = panel.getMarkupAttributes();
assertNotNull(attr);
assertEquals("myPanel", attr.getString("wicket:id"));
label = (Label) page.get("myPanel:label");
assertNotNull(label);
attr = label.getMarkupAttributes();
assertNotNull(attr);
assertEquals("label", attr.getString("wicket:id"));
Border border = (Border) page.get("myBorder");
assertNotNull(border);
attr = border.getMarkupAttributes();
assertNotNull(attr);
assertEquals("myBorder", attr.getString("wicket:id"));
border = (Border) page.get("myBorder2");
assertNotNull(border);
attr = border.getMarkupAttributes();
assertNotNull(attr);
assertEquals("myBorder2", attr.getString("wicket:id"));
// do the same test twice. Igor reported a problem with that, so we have to test it.
border = (Border) page.get("myBorder2");
assertNotNull(border);
attr = border.getMarkupAttributes();
assertNotNull(attr);
assertEquals("myBorder2", attr.getString("wicket:id"));
WebMarkupContainer container = (WebMarkupContainer) page.get("test");
assertNotNull(container);
attr = container.getMarkupAttributes();
assertNotNull(attr);
assertEquals("test", attr.getString("wicket:id"));
label = (Label) page.get("test:myLabel2");
assertNotNull(label);
attr = label.getMarkupAttributes();
assertNotNull(attr);
assertEquals("myLabel2", attr.getString("wicket:id"));
}
use of org.apache.wicket.markup.html.border.Border in project wicket by apache.
the class MarkupFragmentTest method border.
/**
* @throws Exception
*/
@Test
public void border() throws Exception {
Page page = new MyBorderPage();
Border border = (Border) page.get("border");
// Get the associated markup file
IMarkupFragment markup = border.getAssociatedMarkup();
compareMarkupWithFile(markup, "MyBorder_ExpectedResult.html", MyPage.class);
// getMarkup() returns the "calling" tags
markup = border.getMarkup();
compareMarkupWithString(markup, "<span wicket:id=\"border\">test</span>");
// getMarkup(null) returns the markup which is used to find a child component
markup = border.getMarkup(null);
compareMarkupWithString(markup, "<wicket:border> 111 <wicket:body/> 222</wicket:border>");
assertNull(border.getBodyContainer().getAssociatedMarkup());
border.dequeue();
markup = border.getBodyContainer().getMarkup();
compareMarkupWithString(markup, "<wicket:body/>");
markup = border.getBodyContainer().getMarkup(null);
compareMarkupWithString(markup, "<span wicket:id=\"border\">test</span>");
markup = border.getBodyContainer().getParent().getMarkup(border.getBodyContainer());
compareMarkupWithString(markup, "<wicket:body/>");
// getMarkup(null) returns the markup which is used to find a child component
markup = border.getBodyContainer().getMarkup(null);
compareMarkupWithString(markup, "<span wicket:id=\"border\">test</span>");
}
Aggregations