use of org.apache.wicket.Page 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>");
}
use of org.apache.wicket.Page 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.Page 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>");
}
use of org.apache.wicket.Page in project wicket by apache.
the class MarkupFragmentTest method fragments.
/**
* @throws Exception
*/
@Test
public void fragments() throws Exception {
Page page = new InlinePanelPage_1();
Fragment fragment = (Fragment) page.get("myPanel1");
// Get the associated markup file
IMarkupFragment markup = fragment.getAssociatedMarkup();
assertNull(markup);
// getMarkup() returns the "calling" tags
markup = fragment.getMarkup();
compareMarkupWithString(markup, "<span wicket:id=\"myPanel1\">panel</span>");
// getMarkup(null) returns the markup which is used to find a child component
markup = fragment.getMarkup(null);
compareMarkupWithString(markup, "<wicket:fragment wicket:id=\"frag1\">panel 1</wicket:fragment>");
}
use of org.apache.wicket.Page in project wicket by apache.
the class ModalWindow method getWindowOpenJavaScript.
/**
* Returns the javascript used to open the window. Subclass
* {@link #postProcessSettings(AppendingStringBuffer)} to modify the JavaScript if needed.
*
* See WICKET-12
*
* @return javascript that opens the window
*/
protected final String getWindowOpenJavaScript() {
JSONObject settings = new JSONObject();
settings.put("minWidth", getMinimalWidth());
settings.put("minHeight", getMinimalHeight());
settings.put("className", getCssClassName());
settings.put("width", getInitialWidth());
if ((isUseInitialHeight() == true) || (isCustomComponent() == false)) {
settings.put("height", getInitialHeight());
} else {
settings.put("height", (Object) null);
}
settings.put("resizable", isResizable());
if (isResizable() == false) {
settings.put("widthUnit", getWidthUnit());
settings.put("heightUnit", getHeightUnit());
}
if (isCustomComponent() == false) {
Page page = createPage();
if (page == null) {
throw new WicketRuntimeException("Error creating page for modal dialog.");
}
CharSequence pageUrl;
RequestCycle requestCycle = RequestCycle.get();
page.getSession().getPageManager().touchPage(page);
if (page.isPageStateless()) {
pageUrl = requestCycle.urlFor(page.getClass(), page.getPageParameters());
} else {
IRequestHandler handler = new RenderPageRequestHandler(new PageProvider(page));
pageUrl = requestCycle.urlFor(handler);
}
settings.put("src", pageUrl);
} else {
settings.put("element", new JSONFunction("document.getElementById(\"" + getContentMarkupId() + "\")"));
}
if (getCookieName() != null) {
settings.put("cookieId", getCookieName());
}
String title = getTitle() != null ? getTitle().getObject() : null;
if (title != null) {
settings.put("title", getDefaultModelObjectAsString(title));
}
if (getMaskType() == MaskType.TRANSPARENT) {
settings.put("mask", "transparent");
} else if (getMaskType() == MaskType.SEMI_TRANSPARENT) {
settings.put("mask", "semi-transparent");
}
settings.put("autoSize", autoSize);
settings.put("unloadConfirmation", showUnloadConfirmation());
// set true if we set a windowclosedcallback
boolean haveCloseCallback = false;
// notification request
if (windowClosedCallback != null) {
WindowClosedBehavior behavior = getBehaviors(WindowClosedBehavior.class).get(0);
settings.put("onClose", new JSONFunction("function() { " + behavior.getCallbackScript() + " }"));
haveCloseCallback = true;
}
// close window property (thus cleaning the shown flag)
if ((closeButtonCallback != null) || (haveCloseCallback == false)) {
CloseButtonBehavior behavior = getBehaviors(CloseButtonBehavior.class).get(0);
settings.put("onCloseButton", new JSONFunction("function() { " + behavior.getCallbackScript() + "; return false; }"));
}
postProcessSettings(settings);
AppendingStringBuffer buffer = new AppendingStringBuffer(500);
buffer.append("var settings = ");
buffer.append(settings.toString());
buffer.append(";");
buffer.append(getShowJavaScript());
return buffer.toString();
}
Aggregations