Buy me a coffee :)

Wicket - jQuery UI

jQuery UI integration in Wicket 6.x, Wicket 7.x , Wicket 8.x & Wicket 9.x

Snippet Plugin (sample) - the widget, with options

<h1>H1 tag!</h1>
<iframe src="index.html"></iframe>
<div id="foo">
<h3>H3 html is awesome!</h3>
<span class="bar">Womp.</span>
<!-- comment -->
click here
</div>

Components / Samples

Description

Sources

package com.googlecode.wicket.jquery.ui.samples.jqueryui.plugins;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;

import com.googlecode.wicket.jquery.ui.form.button.AjaxButton;
import com.googlecode.wicket.jquery.ui.plugins.SnippetLabel;

public class OptionSnippetPage extends AbstractSnippetPage
{
	private static final long serialVersionUID = 1L;

	/**
	 * @return the Model to be used as source for the SnippetLabel
	 */
	private static IModel<String> newSnippetModel()
	{
		return new LoadableDetachableModel<String>() {

			private static final long serialVersionUID = 1L;

			@Override
			protected String load()
			{
				return	"<h1>H1 tag!</h1>\n" +
					"<iframe src=\"index.html\"></iframe>\n" +
					"<div id=\"foo\">\n" +
					"<h3>H3 html is awesome!</h3>\n" +
					"<span class=\"bar\">Womp.</span>\n" +
					"<!-- comment -->\n" +
					"click here\n" +
					"</div>\n";
			}
		};
	}


	public OptionSnippetPage()
	{
		// Form //
		Form<Void> form = new Form<Void>("form");
		this.add(form);

		// SnippetLabel //
		final WebMarkupContainer container = new WebMarkupContainer("container");
		this.add(container.setOutputMarkupId(true));

		final SnippetLabel label = new SnippetLabel("code", "html", newSnippetModel());
		label.setStyle("ide-eclipse");
		container.add(label);

		// Buttons //
		form.add(new AjaxButton("style1", Model.of("ide-eclipse")) {

			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(AjaxRequestTarget target)
			{
				label.setStyle(this.getModelObject());
				target.add(container);
			}
		});

		form.add(new AjaxButton("style2", Model.of("blacknblue")) {

			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(AjaxRequestTarget target)
			{
				label.setStyle(this.getModelObject());
				target.add(container);
			}
		});
	}
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
	<title>Wicket jQuery UI: plugin / snippet</title>
</wicket:head>
</head>
<body>
<wicket:extend>
	<form wicket:id="form">
		<input type="button" wicket:id="style1" />
		<input type="button" wicket:id="style2" />
	</form>
	<div wicket:id="container" style="width: 90%">
		<pre wicket:id="code"></pre>
	</div>
</wicket:extend>
</body>
</html>