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 text field which automatically adds a Required. This is mainly for convenience, since you can 023 * always add(new Required()) manually. 024 * 025 * @author Jonathan Locke 026 * @param <T> 027 * the model object's type 028 */ 029public class RequiredTextField<T> extends TextField<T> 030{ 031 private static final long serialVersionUID = 1L; 032 033 /** 034 * @see org.apache.wicket.Component#Component(String) 035 */ 036 public RequiredTextField(final String id) 037 { 038 super(id); 039 setRequired(true); 040 } 041 042 /** 043 * @see TextField#TextField(String, Class) 044 */ 045 public RequiredTextField(final String id, final Class<T> type) 046 { 047 super(id, type); 048 setRequired(true); 049 } 050 051 /** 052 * @param id 053 * @param model 054 * @see org.apache.wicket.Component#Component(String, IModel) 055 */ 056 public RequiredTextField(final String id, final IModel<T> model) 057 { 058 super(id, model); 059 setRequired(true); 060 } 061 062 /** 063 * @param id 064 * See Component 065 * @param model 066 * See Component 067 * @param type 068 * The type to use when updating the model for this text field 069 * @see org.apache.wicket.Component#Component(String, IModel) 070 */ 071 public RequiredTextField(final String id, IModel<T> model, Class<T> type) 072 { 073 super(id, model, type); 074 setRequired(true); 075 } 076}