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

org.wicketstuff.kendo.ui.form.NumberTextField 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.form;

import org.apache.wicket.model.IModel;
import org.apache.wicket.util.lang.Args;
import org.wicketstuff.jquery.core.IJQueryWidget;
import org.wicketstuff.jquery.core.JQueryBehavior;
import org.wicketstuff.jquery.core.Options;
import org.wicketstuff.kendo.ui.KendoUIBehavior;

/**
 * Provides a Kendo UI NumericTextBox on the built-in {@link org.apache.wicket.markup.html.form.NumberTextField}
 *
 * @param  the model object type
 * @author Sebastien Briquet - sebfz1
 *
 */
public class NumberTextField> extends org.apache.wicket.markup.html.form.NumberTextField implements IJQueryWidget
{
	private static final long serialVersionUID = 1L;

	public static final String METHOD = "kendoNumericTextBox";

	protected final Options options;

	/**
	 * Constructor
	 *
	 * @param id the markup id
	 */
	public NumberTextField(String id)
	{
		this(id, new Options());
	}

	/**
	 * Constructor
	 *
	 * @param id the markup id
	 * @param options the {@link Options}
	 */
	public NumberTextField(String id, Options options)
	{
		super(id);

		this.options = Args.notNull(options, "options");
	}

	/**
	 * Constructor
	 *
	 * @param id the markup id
	 * @param type the type to use when updating the model for this text field
	 */
	public NumberTextField(String id, Class type)
	{
		this(id, type, new Options());
	}

	/**
	 * Constructor
	 *
	 * @param id the markup id
	 * @param type the type to use when updating the model for this text field
	 * @param options the {@link Options}
	 */
	public NumberTextField(String id, Class type, Options options)
	{
		super(id, type);

		this.options = Args.notNull(options, "options");
	}

	/**
	 * Constructor
	 *
	 * @param id the markup id
	 * @param model the {@link IModel}
	 */
	public NumberTextField(String id, IModel model)
	{
		this(id, model, new Options());
	}

	/**
	 * Constructor
	 *
	 * @param id the markup id
	 * @param model the {@link IModel}
	 * @param options the {@link Options}
	 */
	public NumberTextField(String id, IModel model, Options options)
	{
		super(id, model);

		this.options = Args.notNull(options, "options");
	}

	/**
	 * Constructor
	 *
	 * @param id the markup id
	 * @param model the {@link IModel}
	 * @param type the type to use when updating the model for this text field
	 */
	public NumberTextField(String id, IModel model, Class type)
	{
		this(id, model, type, new Options());
	}

	/**
	 * Constructor
	 *
	 * @param id the markup id
	 * @param model the {@link IModel}
	 * @param type the type to use when updating the model for this text field
	 * @param options the {@link Options}
	 */
	public NumberTextField(String id, IModel model, Class type, Options options)
	{
		super(id, model, type);

		this.options = Args.notNull(options, "options");
	}

	// Events //

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

		this.add(JQueryWidget.newWidgetBehavior(this)); // cannot be in ctor as the markupId may be set manually afterward
	}

	@Override
	public void onConfigure(JQueryBehavior behavior)
	{
		// noop
	}

	@Override
	public void onBeforeRender(JQueryBehavior behavior)
	{
		// noop
	}

	// IJQueryWidget //

	@Override
	public JQueryBehavior newWidgetBehavior(String selector)
	{
		return new KendoUIBehavior(selector, NumberTextField.METHOD, this.options);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy