Buy me a coffee :)

Wicket - jQuery UI

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

Button

Link

Components / Samples

Description

The Button class inherits from org.apache.wicket.markup.html.form.Button.
It means that you can use a button exactly as built-in Wicket one, except that it looks like the jQuery one.

Button button = new Button("button1") {

	@Override
	public void onSubmit() {
				
	}			
};

Sources

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

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.Model;

import com.googlecode.wicket.jquery.ui.form.button.Button;
import com.googlecode.wicket.jquery.ui.markup.html.link.SubmitLink;
import com.googlecode.wicket.jquery.ui.panel.JQueryFeedbackPanel;

public class DefaultButtonPage extends AbstractButtonPage
{
	private static final long serialVersionUID = 1L;

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

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

		// Buttons //
		form.add(new Button("button1", Model.of("Submit")) { // the model here is used to retrieve the button's text afterward

			private static final long serialVersionUID = 1L;

			@Override
			public void onSubmit()
			{
				DefaultButtonPage.this.info(this);
			}
		});

		form.add(new Button("button2", Model.of("Submit, with client click")) { // idem as previous comment

			private static final long serialVersionUID = 1L;

			@Override
			protected String getOnClickScript()
			{
				return "alert('The button has been clicked!');";
			}

			@Override
			public void onSubmit()
			{
				DefaultButtonPage.this.info(this);
			}
		});

		form.add(new SubmitLink("link", Model.of("Link")) {

			private static final long serialVersionUID = 1L;

			@Override
			public void onSubmit()
			{
				DefaultButtonPage.this.info(this);
			}
		});
	}

	private void info(Component component)
	{
		this.info(String.format("'%s' has been clicked", component.getDefaultModelObjectAsString()));
	}
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
	<title>Wicket jQuery UI: button</title>
</wicket:head>
</head>
<body>
<wicket:extend>
	<div id="demo-panel">
		<form wicket:id="form">
			<input wicket:id="button1" type="submit" value="Submit" />
			<button wicket:id="button2" type="submit">Submit, with client onclick</button>
			<a wicket:id="link" href="javascript:;">Link</a>
			<br/><br/>
			<div wicket:id="feedback" style="width: 360px;"></div>
		</form>
	</div>
</wicket:extend>
</body>
</html>