Buy me a coffee :)

Wicket - jQuery UI

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

Slider

15



Components / Samples

Description

The Slider is a form component, having a IModel<Integer>.
Additionally a Label could be used to dynamically display the value as it's changing

Sources

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

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.Model;

import com.googlecode.wicket.jquery.core.resource.StyleSheetPackageHeaderItem;
import com.googlecode.wicket.jquery.ui.form.button.AjaxButton;
import com.googlecode.wicket.jquery.ui.form.button.Button;
import com.googlecode.wicket.jquery.ui.form.slider.Slider;
import com.googlecode.wicket.jquery.ui.panel.JQueryFeedbackPanel;

public class DefaultSliderPage extends AbstractSliderPage
{
	private static final long serialVersionUID = 1L;

	public DefaultSliderPage()
	{
		final Form<Integer> form = new Form<Integer>("form", Model.of(15));
		this.add(form);

		// FeedbackPanel //
		form.add(new JQueryFeedbackPanel("feedback"));

		// Sliders //
		final Label label = new Label("label", form.getModel()); // the supplied model allows the initial display
		form.add(label);

		form.add(new Slider("slider", form.getModel(), label)); // will use the html markupId

		// Buttons //
		form.add(new Button("submit") {

			private static final long serialVersionUID = 1L;

			@Override
			public void onSubmit()
			{
				DefaultSliderPage.this.info(this, form);
			}
		});

		form.add(new AjaxButton("button") {

			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(AjaxRequestTarget target)
			{
				DefaultSliderPage.this.info(this, form);
				target.add(form);
			}
		});
	}

	// Methods //

	@Override
	public void renderHead(IHeaderResponse response)
	{
		super.renderHead(response);

		response.render(new StyleSheetPackageHeaderItem(DefaultSliderPage.class));
	}

	private void info(Component component, Form<?> form)
	{
		this.info(component.getMarkupId() + " has been clicked");
		this.info("The model object is: " + form.getModelObject());
	}
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
	<title>Wicket jQuery UI: slider</title>
</wicket:head>
</head>
<body>
<wicket:extend>
	<div id="demo-panel">
		<form wicket:id="form">
			<table>
				<tr>
					<td style="width: 240px;">
						<div wicket:id="slider"></div>
					</td>
					<td style="width: 100px;">
						<span wicket:id="label" id="label"></span>
					</td>
				</tr>
			</table>
			<br/>
			<button wicket:id="submit" type="submit">Submit</button>
			<button wicket:id="button">Ajax Button</button>
			<br/><br/>
			<div wicket:id="feedback" style="width: 360px;"></div>
		</form>
	</div>
</wicket:extend>
</body>
</html>
th, td {
	padding: 5px;
}

table {
	width: 340px;
}