Buy me a coffee :)

Wicket - jQuery UI

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

AccordionPanel



  • Tab (SimpleTab)
    My content !
  • Tab (AbstractTab)
    Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
  • Tab (AjaxTab)
    Loading...

Components / Samples

Description

Since

wicket-kendo-ui-6.19.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.accordion;

import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.lang.Generics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.googlecode.wicket.jquery.core.resource.StyleSheetPackageHeaderItem;
import com.googlecode.wicket.kendo.ui.form.button.AjaxButton;
import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel;
import com.googlecode.wicket.kendo.ui.widget.accordion.AccordionPanel;
import com.googlecode.wicket.kendo.ui.widget.tabs.AjaxTab;
import com.googlecode.wicket.kendo.ui.widget.tabs.SimpleTab;

public class KendoAccordionPanelPage extends AbstractAccordionPage
{
	private static final long serialVersionUID = 1L;
	private static final Logger LOG = LoggerFactory.getLogger(KendoAccordionPanelPage.class);
	
	public KendoAccordionPanelPage()
	{
		final Form<?> form = new Form<Void>("form");
		this.add(form);

		// Feedback Panel //
		final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback");
		form.add(feedback.setOutputMarkupId(true));

		// Accordion //
		final AccordionPanel accordion = new AccordionPanel("accordion", this.newTabList()) {

			private static final long serialVersionUID = 1L;
			
			@Override
			public boolean isExpandEventEnabled()
			{
				return true;
			}

			@Override
			public void onSelect(AjaxRequestTarget target, int index, ITab tab)
			{
				info(String.format("selected tab: #%d - %s", index, tab.getTitle().getObject()));
				target.add(feedback);
			}
		};

		form.add(accordion);

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

			private static final long serialVersionUID = 1L;

			@Override
			protected void onSubmit(AjaxRequestTarget target)
			{
				accordion.setTabIndex(accordion.getLastTabIndex(), target);
			}
		});
	}

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

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

	private List<ITab> newTabList()
	{
		List<ITab> tabs = Generics.newArrayList();

		// tab #1, using SimpleTab //
		tabs.add(new SimpleTab(Model.of("Tab (SimpleTab)"), Model.of("My content !")));

		// tab #2, invisible Tab //
		tabs.add(new SimpleTab(Model.of("Tab (invisible)"), Model.of("")) {

			private static final long serialVersionUID = 1L;

			@Override
			public boolean isVisible()
			{
				return false;
			}
		});

		// tab #3, using AbstractTab //
		tabs.add(new AbstractTab(Model.of("Tab (AbstractTab)")) {

			private static final long serialVersionUID = 1L;

			@Override
			public WebMarkupContainer getPanel(String panelId)
			{
				return new Fragment(panelId, "panel-1", KendoAccordionPanelPage.this);
			}
		});

		// tab #4, using AjaxTab //
		tabs.add(new AjaxTab(Model.of("Tab (AjaxTab)")) {

			private static final long serialVersionUID = 1L;

			@Override
			public WebMarkupContainer getLazyPanel(String panelId)
			{
				try
				{
					// sleep the thread to simulate a long load
					Thread.sleep(500);
				}
				catch (InterruptedException e)
				{
					if (LOG.isDebugEnabled())
					{
						LOG.debug(e.getMessage(), e);
					}
				}

				return new Fragment(panelId, "panel-2", KendoAccordionPanelPage.this);
			}
		});

		return tabs;
	}
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
	<title>Wicket - Kendo UI: accordion panel</title>
</wicket:head>
</head>
<body>
<wicket:extend>
	<form wicket:id="form">
		<button wicket:id="button" class="float-right">Activate Last</button><br/>
		<br class="clear-both" />

		<div wicket:id="accordion"></div>
		<br/>
		<div wicket:id="feedback"></div>
	</form>

	<wicket:fragment wicket:id="panel-1">
		Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
	</wicket:fragment>

	<wicket:fragment wicket:id="panel-2">
		<b>Panel loaded in ajax</b><br/>
		<p>
			Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna.
		</p>
	</wicket:fragment>
</wicket:extend>
</body>
</html>
UL>LI .k-content {
	padding: 12px !important;
}

UL>LI DIV P {
	margin: 0;
}