Skip to content

Instantly share code, notes, and snippets.

@jonnywray
jonnywray / ConsoleJsonWriter.java
Last active December 20, 2018 20:54
Generic JSON reporter for Dropwizard metrics (https://dropwizard.github.io/metrics/3.1.0/) for sending JSON representation to arbitrary HTTP endpoint
import com.codahale.metrics.MetricFilter;
import com.codahale.metrics.MetricRegistry;
import com.fasterxml.jackson.databind.SerializationFeature;
import java.io.PrintStream;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@jonnywray
jonnywray / OutlookPanel$ControlPanel.html
Created May 11, 2011 23:57
Wicket component implementing an Outlook panel
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd" xml:lang="en" lang="en">
<wicket:panel>
<div class="outlook-control-title"><a href="#" wicket:id="link"><span wicket:id="title">[[tab title]]</span></a></div>
<div class="outlook-control-content" wicket:id="content">[]</div>
</wicket:panel>
</html>
@jonnywray
jonnywray / AjaxDynamicTabbedPanel.java
Created May 11, 2011 23:55
Wicket component for a tabbed panel that gets tab definitions from a model thus allowing tabs to be defined dynamically
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;
import java.util.List;
/**
* Ajax based extension of the dynamic tabbed panel
@jonnywray
jonnywray / AjaxBlockUIDecorator.java
Created May 11, 2011 23:51
Wicket decorator that uses jQuery to block the UI while an Ajax request completes
import org.apache.wicket.Component;
import org.apache.wicket.ajax.calldecorator.AjaxCallDecorator;
/**
* Ajax call decorator to block the page while the Ajax callback
* occurs.
*
* For some reason the jQuery plugin used for this decorator continues
* with a spinning wheel after the response is done until focus leaves
* the form component. Same thing happens on their web site. Find a better
@jonnywray
jonnywray / DynamicImageMap.java
Created October 26, 2010 16:55
Wicket and JFreeChart integration including image map for tooltips and clickable graph
import org.apache.wicket.ajax.AjaxEventBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.IAjaxCallDecorator;
import org.apache.wicket.ajax.calldecorator.CancelEventIfNoAjaxDecorator;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.RefreshingView;
import org.apache.wicket.markup.repeater.util.ModelIteratorAdapter;
@jonnywray
jonnywray / FutureUpdateBehavior.java
Last active September 3, 2021 15:16
Wicket FutureUpdateBehavior: allows asynchronous update of components.
import org.apache.wicket.ajax.AbstractAjaxTimerBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.util.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@jonnywray
jonnywray / gist:594504
Created September 23, 2010 22:19
Wicket StopFormSubmitBehaviour: allows non Ajax form submits (e.g. return press) to go via Ajax route
import org.apache.wicket.Component;
import org.apache.wicket.behavior.AbstractBehavior;
import org.apache.wicket.markup.html.IHeaderResponse;
/**
* Behavior to allow non ajax form submits (eg press return) to go via the Ajax
* submit route. Note that it requires the prototype.js javascript library.
*
* @author <a href="http://richard-wilkinson.co.uk/2008/04/05/how-to-stop-non-ajax-form-submits-in-wicket/">Richard Wilkinson</a>
@jonnywray
jonnywray / gist:594489
Created September 23, 2010 22:12
Wicket CollapsiblePanel: allows the show and hide of an inner panel while keeping a header and border
import org.apache.wicket.ResourceReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
/**
@jonnywray
jonnywray / AsynchronousUpdatePanel.java
Last active October 10, 2017 02:00
Wicket AsynchronousUpdatePanel: allows asynchronous rendering of expensive to create panels
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.resource.PackageResourceReference;