Search in sources :

Example 6 with Border

use of org.apache.wicket.markup.html.border.Border in project wicket by apache.

the class SimplePageTest method renderHomePage_2a.

/**
 * @throws Exception
 */
@Test
public void renderHomePage_2a() throws Exception {
    // Render the component without having rendered the page previously
    SimplePage page = new SimplePage();
    tester.startPage(page);
    String document = tester.getLastResponseAsString();
    Label label = (Label) page.get("myLabel");
    assertNotNull(label);
    assertTrue(document.contains("<span wicket:id=\"myLabel\">Test Label</span>"));
    Panel panel = (Panel) page.get("myPanel");
    assertNotNull(panel);
    assertTrue(document.contains("<wicket:panel>Inside the panel<span wicket:id=\"label\">mein Label</span></wicket:panel>"));
    label = (Label) page.get("myPanel:label");
    assertNotNull(label);
    assertTrue(document.contains("<span wicket:id=\"label\">mein Label</span>"));
    Border border = (Border) page.get("myBorder");
    assertNotNull(border);
    assertTrue(document.contains("<wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border>"));
    border = (Border) page.get("myBorder2");
    assertNotNull(border);
    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) page.get("myBorder2");
    assertNotNull(border);
    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) page.get("test");
    assertNotNull(container);
    assertTrue(document.contains("body<span wicket:id=\"myLabel2\">Test Label2</span>"));
    label = (Label) page.get("test:myLabel2");
    assertNotNull(label);
    assertTrue(document.contains("<span wicket:id=\"myLabel2\">Test Label2</span>"));
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) Border(org.apache.wicket.markup.html.border.Border) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Test(org.junit.Test)

Example 7 with Border

use of org.apache.wicket.markup.html.border.Border in project wicket by apache.

the class MarkupContainer method dequeueChild.

/**
 * Propagates dequeuing to child component.
 *
 * @param child
 *             the child component
 * @param tag
 *             the child tag
 * @param dequeue
 *             the dequeue context to use
 */
private void dequeueChild(Component child, ComponentTag tag, DequeueContext dequeue) {
    ChildToDequeueType childType = ChildToDequeueType.fromChild(child);
    if (childType == ChildToDequeueType.QUEUE_REGION || childType == ChildToDequeueType.BORDER) {
        ((IQueueRegion) child).dequeue();
    }
    if (childType == ChildToDequeueType.BORDER) {
        Border childContainer = (Border) child;
        // propagate dequeuing to border's body
        MarkupContainer body = childContainer.getBodyContainer();
        dequeueChildrenContainer(dequeue, body);
    }
    if (childType == ChildToDequeueType.MARKUP_CONTAINER) {
        // propagate dequeuing to containers
        MarkupContainer childContainer = (MarkupContainer) child;
        dequeueChildrenContainer(dequeue, childContainer);
    }
    if (childType == ChildToDequeueType.NULL || childType == ChildToDequeueType.QUEUE_REGION) {
        dequeue.skipToCloseTag();
    }
    // pull the close tag off
    ComponentTag close = dequeue.takeTag();
    do {
        if (close != null && close.closes(tag)) {
            return;
        }
    } while ((close = dequeue.takeTag()) != null);
    throw new IllegalStateException(String.format("Could not find the closing tag for '%s'", tag));
}
Also used : ComponentTag(org.apache.wicket.markup.ComponentTag) Border(org.apache.wicket.markup.html.border.Border)

Example 8 with Border

use of org.apache.wicket.markup.html.border.Border in project wicket by apache.

the class MarkupParserTest method parseBorderSintax.

/**
 * @throws IOException
 * @throws ResourceStreamNotFoundException
 */
@Test
public void parseBorderSintax() throws IOException, ResourceStreamNotFoundException {
    tester.getApplication().getPageSettings().addComponentResolver(new Border("test_resolver") {

        /**
         */
        private static final long serialVersionUID = 1L;
    });
    String x = "<wicket:border>before body - <wicket:body/> - after body</wicket:border>";
    MarkupParser parser = new MarkupParser(x);
    Markup markup = parser.parse();
    assertEquals(x, markup.toString(true));
}
Also used : Border(org.apache.wicket.markup.html.border.Border) Test(org.junit.Test)

Example 9 with Border

use of org.apache.wicket.markup.html.border.Border in project wicket by apache.

the class ComponentQueueingTest method border_nested.

@Test
public void border_nested() {
    MarkupContainer a = new A(), b = new B(), c = new C(), d = new D(), r = new R(), s = new S();
    Border outerBorder = new OuterBorder("outerBorder");
    Border innerBorder = new InnerBorder("innerBorder");
    outerBorder.queueToBorder(r, innerBorder);
    innerBorder.queueToBorder(c, d);
    outerBorder.queueToBorder(s);
    TestPage p = new TestPage();
    p.setPageMarkup("<p wicket:id='a'><p wicket:id='outerBorder'><p wicket:id='b'></p></p></p>");
    p.queue(b, outerBorder, a);
    tester.startPage(p);
    assertThat(p, hasPath(new Path(a, outerBorder, r, innerBorder, c, d, innerBorder.getBodyContainer(), s)));
    assertThat(p, hasPath(new Path(a, outerBorder, r, outerBorder.getBodyContainer(), b)));
}
Also used : WicketMatchers.hasPath(org.apache.wicket.queueing.WicketMatchers.hasPath) MarkupContainer(org.apache.wicket.MarkupContainer) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TransparentWebMarkupContainer(org.apache.wicket.markup.html.TransparentWebMarkupContainer) OuterBorder(org.apache.wicket.queueing.nestedborders.OuterBorder) InnerBorder(org.apache.wicket.queueing.nestedborders.InnerBorder) OuterBorder(org.apache.wicket.queueing.nestedborders.OuterBorder) Border(org.apache.wicket.markup.html.border.Border) InnerBorder(org.apache.wicket.queueing.nestedborders.InnerBorder) Test(org.junit.Test)

Aggregations

Border (org.apache.wicket.markup.html.border.Border)9 Test (org.junit.Test)7 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 Panel (org.apache.wicket.markup.html.panel.Panel)3 MarkupContainer (org.apache.wicket.MarkupContainer)2 Page (org.apache.wicket.Page)2 IMarkupFragment (org.apache.wicket.markup.IMarkupFragment)2 ComponentTag (org.apache.wicket.markup.ComponentTag)1 TransparentWebMarkupContainer (org.apache.wicket.markup.html.TransparentWebMarkupContainer)1 WicketMatchers.hasPath (org.apache.wicket.queueing.WicketMatchers.hasPath)1 InnerBorder (org.apache.wicket.queueing.nestedborders.InnerBorder)1 OuterBorder (org.apache.wicket.queueing.nestedborders.OuterBorder)1 PackageResourceReference (org.apache.wicket.request.resource.PackageResourceReference)1 ValueMap (org.apache.wicket.util.value.ValueMap)1