Search in sources :

Example 6 with IMarkupFragment

use of org.apache.wicket.markup.IMarkupFragment in project wicket by apache.

the class MarkupFragmentTest method panelWithAutoComponent.

/**
 * @see href http://issues.apache.org/jira/browse/WICKET-3111
 *
 * @throws Exception
 */
@Test
public void panelWithAutoComponent() throws Exception {
    Page page = new MyPage();
    Panel panel = new MyPanelWithAutoComponent("panel");
    page.add(panel);
    // Get the associated markup file
    IMarkupFragment markup = panel.getAssociatedMarkup();
    compareMarkupWithFile(markup, "MyPanelWithAutoComponent_ExpectedResult.html", MyPage.class);
    // The Page is missing the tag to "call" the panel
    assertNull(panel.getMarkup());
    // Create a Page with proper markup for the panel
    page = new MyPanelWithAutoComponentPage();
    panel = (Panel) page.get("panel");
    // getMarkup() returns the "calling" tags
    markup = panel.getMarkup();
    compareMarkupWithString(markup, "<span wicket:id=\"panel\">test</span>");
    // getMarkup(null) returns the markup which is used to find a child component
    markup = panel.getMarkup(null);
    compareMarkupWithString(markup, "<wicket:panel><a href=\"something\"><span wicket:id=\"label\">text</span></a></wicket:panel>");
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) Page(org.apache.wicket.Page) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) Test(org.junit.Test)

Example 7 with IMarkupFragment

use of org.apache.wicket.markup.IMarkupFragment 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>");
}
Also used : Page(org.apache.wicket.Page) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) Border(org.apache.wicket.markup.html.border.Border) Test(org.junit.Test)

Example 8 with IMarkupFragment

use of org.apache.wicket.markup.IMarkupFragment in project wicket by apache.

the class MarkupFragmentTest method page.

/**
 * page.getAssociatedMarkup(), page.getMarkup() and page.getMarkup(null) must all return the
 * same
 *
 * @throws Exception
 */
@Test
public void page() throws Exception {
    IMarkupFragment markup = new MyPage().getAssociatedMarkup();
    compareMarkupWithFile(markup, "MyPage_ExpectedResult.html", MyPage.class);
    markup = new MyPage().getMarkup();
    compareMarkupWithFile(markup, "MyPage_ExpectedResult.html", MyPage.class);
    markup = new MyPage().getMarkup(null);
    compareMarkupWithFile(markup, "MyPage_ExpectedResult.html", MyPage.class);
}
Also used : IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) Test(org.junit.Test)

Example 9 with IMarkupFragment

use of org.apache.wicket.markup.IMarkupFragment in project wicket by apache.

the class MarkupFragmentTest method panel.

/**
 * @throws Exception
 */
@Test
public void panel() throws Exception {
    Page page = new MyPage();
    Panel panel = new MyPanel("panel");
    page.add(panel);
    // Get the associated markup file
    IMarkupFragment markup = panel.getAssociatedMarkup();
    compareMarkupWithFile(markup, "MyPanel_ExpectedResult.html", MyPage.class);
    // The Page is missing the tag to "call" the panel
    assertNull(panel.getMarkup());
    // Create a Page with proper markup for the panel
    page = new MyPanelPage();
    panel = (Panel) page.get("panel");
    // getMarkup() returns the "calling" tags
    markup = panel.getMarkup();
    compareMarkupWithString(markup, "<span wicket:id=\"panel\">test</span>");
    // getMarkup(null) returns the markup which is used to find a child component, which in case
    // of Panel is the <wicket:panel> tag and is thus may not be equal to the associated markup
    // file.
    markup = panel.getMarkup(null);
    compareMarkupWithString(markup, "<wicket:panel>  <span wicket:id=\"label\">text</span></wicket:panel>");
}
Also used : Panel(org.apache.wicket.markup.html.panel.Panel) Page(org.apache.wicket.Page) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) Test(org.junit.Test)

Example 10 with IMarkupFragment

use of org.apache.wicket.markup.IMarkupFragment in project wicket by apache.

the class MarkupFragmentTest method label.

/**
 * @throws Exception
 */
@Test
public void label() throws Exception {
    Component label = new MyPage().get("label");
    IMarkupFragment markup = label.getMarkup();
    compareMarkupWithString(markup, "<span wicket:id=\"label\">text</span>");
    label = new MyPanelPage().get("panel:label");
    markup = label.getMarkup();
    compareMarkupWithString(markup, "<span wicket:id=\"label\">text</span>");
}
Also used : Component(org.apache.wicket.Component) IMarkupFragment(org.apache.wicket.markup.IMarkupFragment) Test(org.junit.Test)

Aggregations

IMarkupFragment (org.apache.wicket.markup.IMarkupFragment)26 Test (org.junit.Test)8 Page (org.apache.wicket.Page)6 ComponentTag (org.apache.wicket.markup.ComponentTag)6 MarkupStream (org.apache.wicket.markup.MarkupStream)6 MarkupContainer (org.apache.wicket.MarkupContainer)5 MarkupException (org.apache.wicket.markup.MarkupException)4 Component (org.apache.wicket.Component)3 MarkupElement (org.apache.wicket.markup.MarkupElement)3 MarkupNotFoundException (org.apache.wicket.markup.MarkupNotFoundException)3 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)2 MarkupResourceStream (org.apache.wicket.markup.MarkupResourceStream)2 WicketTag (org.apache.wicket.markup.WicketTag)2 Border (org.apache.wicket.markup.html.border.Border)2 Panel (org.apache.wicket.markup.html.panel.Panel)2 IComponentResolver (org.apache.wicket.markup.resolver.IComponentResolver)2 IOException (java.io.IOException)1 List (java.util.List)1