Buy me a coffee :)

Wicket - jQuery UI

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

Context Menu


Components / Samples

Description

Since

wicket-kendo-ui-6.20.0

Licensing

Kendo UI "Core" is Apache License 2.0 licensed, starting from version 2014.1.416.
Prior to version 2014.1.416, Kendo UI "Web" was licensed under GPLv3.

A pro version - with a commercial license - is also available, it provides additional widgets (see http://docs.telerik.com/kendo-ui/intro/supporting/list-of-widgets)
To be able to use it, you need to change the ResourceReference with kendo.all.min.js

See also

[howto]-change-resource-references

Sources

  • Java
  • HTML
  • CSS
package com.googlecode.wicket.jquery.ui.samples.kendoui.menu;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.list.ListItem;

import com.googlecode.wicket.jquery.core.JQueryBehavior;
import com.googlecode.wicket.jquery.core.Options;
import com.googlecode.wicket.jquery.ui.samples.kendoui.menu.KendoMenuPage.MoveToPositionMenuItem;
import com.googlecode.wicket.jquery.ui.samples.kendoui.menu.KendoMenuPage.MoveToPositionPanel;
import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel;
import com.googlecode.wicket.kendo.ui.widget.menu.ContextMenu;
import com.googlecode.wicket.kendo.ui.widget.menu.item.IMenuItem;

public class KendoContextMenuPage extends AbstractMenuPage
{
	private static final long serialVersionUID = 1L;

	public KendoContextMenuPage()
	{
		// FeedbackPanel //
		final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback");
		this.add(feedback);

		// Context Menu //
		this.add(new ContextMenu("menu", KendoMenuPage.newMenuItemList()) {

			private static final long serialVersionUID = 1L;

			// methods //

			@Override
			protected void addMenuItem(ListItem<IMenuItem> item, IMenuItem menuItem)
			{
				if (menuItem instanceof MoveToPositionMenuItem)
				{
					item.add(new MoveToPositionPanel("item", (MoveToPositionMenuItem) menuItem, KendoContextMenuPage.this));
					item.add(new WebMarkupContainer("menu"));
				}
				else
				{
					super.addMenuItem(item, menuItem);
				}
			}

			// events //

			@Override
			public void onConfigure(JQueryBehavior behavior)
			{
				super.onConfigure(behavior);

				behavior.setOption("target", Options.asString("#menu-target"));
			}

			@Override
			public void onClick(AjaxRequestTarget target, IMenuItem item)
			{
				if (item instanceof MoveToPositionMenuItem)
				{
					MoveToPositionMenuItem moveToPositionMenuItem = (MoveToPositionMenuItem) item;
					this.info("Set the position to: " + moveToPositionMenuItem.getPosition());
				}
				else
				{
					this.info("Clicked " + item.getTitle().getObject());
				}

				this.reload(target);
				target.add(feedback);
			}
		});
	}
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
	<title>Wicket Kendo UI: context menu</title>
</wicket:head>
</head>
<body>
<wicket:extend>
    <div id="menu-target">
        Right click here to display the context menu
    </div>
	<div wicket:id="menu"></div>
	<br/>
	<div wicket:id="feedback"></div>

	<wicket:fragment wicket:id="moveToPosition">
		<form wicket:id="form">
			With a Form: <input wicket:id="position" type="number" style="width: 70px"/> <button type="button" wicket:id="moveToPositionBtn">Set position</button>
		</form>
	</wicket:fragment>

</wicket:extend>
</body>
</html>