001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.markup.html.form; 018 019import org.apache.wicket.model.IModel; 020 021/** 022 * A {@link TextField} for HTML5 <input> with type <em>range</em>. 023 * 024 * <p> 025 * Automatically validates the input against the configured {@link #setMinimum(Number)} min} and 026 * {@link #setMaximum(Number)} max} attributes. If any of them is <code>null</code> then 027 * {@link Double#MIN_VALUE} and {@link Double#MAX_VALUE} are used respectfully. 028 * 029 * @param <N> 030 * the number type 031 */ 032public class RangeTextField<N extends Number & Comparable<N>> extends NumberTextField<N> 033{ 034 private static final long serialVersionUID = 1L; 035 036 /** 037 * Construct. 038 * 039 * @param id 040 * component id 041 */ 042 public RangeTextField(String id) 043 { 044 this(id, null); 045 } 046 047 /** 048 * Construct. 049 * 050 * @param id 051 * see Component 052 * @param model 053 * the model 054 */ 055 public RangeTextField(String id, IModel<N> model) 056 { 057 this(id, model, null); 058 } 059 060 /** 061 * Construct. 062 * 063 * @param id 064 * component id 065 * @param model 066 * the input value 067 * @param type 068 * The type to use when updating the model for this text field 069 */ 070 public RangeTextField(String id, IModel<N> model, Class<N> type) 071 { 072 super(id, model, type); 073 } 074 075 @Override 076 protected String[] getInputTypes() 077 { 078 return new String[] {"range"}; 079 } 080}