All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wicketstuff.kendo.ui.repeater.dataview.DataViewPanel Maven / Gradle / Ivy

There is a newer version: 10.3.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.wicketstuff.kendo.ui.repeater.dataview;

import org.apache.wicket.markup.html.panel.GenericPanel;
import org.apache.wicket.markup.repeater.data.IDataProvider;
import org.wicketstuff.jquery.core.Options;
import org.wicketstuff.jquery.core.renderer.JsonRenderer;
import org.wicketstuff.jquery.core.template.IJQueryTemplate;
import org.wicketstuff.jquery.core.template.JQueryTemplate;
import org.wicketstuff.kendo.ui.KendoDataSource;

/**
 * Provides a simple read-only {@link DataView} with a {@link Pager} panel
 * 
 * @param  the model object type
 * @author Sebastien Briquet - sebfz1
 */
public class DataViewPanel extends GenericPanel // NOSONAR
{
	private static final long serialVersionUID = 1L;

	/** the number of rows to display */
	protected final long rows;

	/** the data-source provider */
	private final IDataProvider provider;

	protected final Options options;

	/**
	 * Constructor
	 *
	 * @param id the markup id
	 * @param provider the {@link IDataProvider}
	 * @param rows the number of rows per page to be displayed
	 */
	public DataViewPanel(String id, final IDataProvider provider, final long rows)
	{
		this(id, provider, rows, new Options());
	}

	/**
	 * Main constructor
	 *
	 * @param id the markup id
	 * @param provider the {@link IDataProvider}
	 * @param rows the number of rows per page to be displayed
	 * @param options the {@link Options}
	 */
	public DataViewPanel(String id, final IDataProvider provider, final long rows, Options options)
	{
		super(id);

		this.rows = rows;
		this.options = options;
		this.provider = provider;
	}

	// Events //

	@Override
	protected void onInitialize()
	{
		super.onInitialize();

		final KendoDataSource dataSource = new KendoDataSource(this);

		this.add(this.newDataView("listView", dataSource, this.provider, this.options));
		this.add(this.newPager("pager", dataSource));
	}

	// Factories //

	/**
	 * Gets a new {@link IJQueryTemplate} to customize the rendering
* The properties used in the template text (ie: ${data.name}) should be of the prefixed by "data."
*
* Note: {@link DataView} uses a {@link JsonRenderer} by default, making {@link IJQueryTemplate#getTextProperties()} not required to override (see {@link JQueryTemplate}) * * @return null by default * @see JQueryTemplate */ protected IJQueryTemplate newTemplate() { return null; } /** * Gets a new {@link DataView} * * @param id the markup id * @param dataSource the {@link KendoDataSource} * @param provider the {@link IDataProvider} * @param options the {@link Options} * @return a new {@code DataView} */ protected DataView newDataView(String id, final KendoDataSource dataSource, IDataProvider provider, Options options) { return new DataView(id, provider, options) { // NOSONAR private static final long serialVersionUID = 1L; // Properties // @Override protected long getRowCount() { return DataViewPanel.this.rows; } // Factories // @Override protected IJQueryTemplate newTemplate() { return DataViewPanel.this.newTemplate(); } @Override protected KendoDataSource newDataSource() { return dataSource; } }; } /** * Gets a new {@link Pager} * * @param id the markup id * @param dataSource the {@link KendoDataSource} * @return a new {@code Pager} */ protected Pager newPager(String id, KendoDataSource dataSource) { return new Pager(id, dataSource); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy