Skip to content

Instantly share code, notes, and snippets.

@joggienl
Last active May 20, 2016 14:49
Show Gist options
  • Save joggienl/3856ed6d5b2d00170690e3ab14e62e08 to your computer and use it in GitHub Desktop.
Save joggienl/3856ed6d5b2d00170690e3ab14e62e08 to your computer and use it in GitHub Desktop.
Plugin with DialogWindow in it.
<?xml version="1.0" encoding="UTF-8" ?>
<wicket:panel xmlns:wicket="http://wicket.apache.org/">
<div class="hippo-editor-field-value">
<div class="hippo-editor-field-value-container">
<div class="hippo-editor-field-subfield dialog-link">
<a wicket:id="openModalDialog" class="linefill">Click to open..</a>
</div>
</div>
</div>
<div wicket:id="modalDialog"></div>
</wicket:panel>
package nl.yeah.plugins.custom;
import org.apache.wicket.Page;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.hippoecm.frontend.dialog.DialogWindow;
import org.hippoecm.frontend.plugin.IPluginContext;
import org.hippoecm.frontend.plugin.config.IPluginConfig;
import org.hippoecm.frontend.service.render.RenderPlugin;
public class NicePlugin extends RenderPlugin {
private static final long serialVersionUID = 1L;
private final DialogWindow modalDialog;
public NicePlugin (IPluginContext context, IPluginConfig config) {
super(context, config);
modalDialog = new DialogWindow("modalDialog");
modalDialog.setPageCreator(new DialogWindow.PageCreator() {
@Override
public Page createPage() {
return new TestPage(modalDialog);
}
});
modalDialog.setWindowClosedCallback(new DialogWindow.WindowClosedCallback() {
public void onClose (AjaxRequestTarget target) {
// Code to do target.add(updated-element);
}
});
modalDialog.setCloseButtonCallback(new DialogWindow.CloseButtonCallback() {
public boolean onCloseButtonClicked (AjaxRequestTarget target) {
return true;
}
});
add(new AjaxLink<Void>("openModalDialog") {
@Override
public void onClick(AjaxRequestTarget target) {
modalDialog.show(target);
}
});
}
}
<!DOCTYPE html>
<html lang="en" xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<meta charset="UTF-8">
<title>No title for you dude!</title>
</wicket:head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-12">
<a wicket-id="closeMe">Close me!</a>
</div>
</div>
</div>
</body>
</html>
package nl.yeah.plugins.custom;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebPage;
import org.hippoecm.frontend.dialog.DialogWindow;
public class TestPage extends WebPage {
public TestPage (final DialogWindow parentWindow) {
super();
setOutputMarkupId(true);
AjaxLink closeMe = new AjaxLink("closeMe") {
@Override
public void onClick(AjaxRequestTarget target) {
parentWindow.close(target);
}
};
add(closeMe);
closeMe.setOutputMarkupId(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment