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 * TextField doesn't permit the html <input type='hidden'> so this is a simple subclass to allow 023 * this 024 * 025 * A HiddenField is useful when you have a javascript based component that updates the form state. 026 * Either 027 * 028 * <ul> 029 * <li>add a AttributeModified to set the id attribute, then use document.getElementById(id)</li> 030 * <li>lookup the field name=getPath() within the form</li> 031 * </ul> 032 * 033 * @author Cameron Braid 034 * @param <T> 035 * the model object's type 036 */ 037public class HiddenField<T> extends TextField<T> 038{ 039 private static final long serialVersionUID = 1L; 040 041 /** 042 * Construct. 043 * 044 * @param id 045 * component id 046 */ 047 public HiddenField(String id) 048 { 049 super(id); 050 } 051 052 /** 053 * Construct. 054 * 055 * @param id 056 * component id 057 * @param type 058 * the type to use when updating the model for this text field 059 */ 060 public HiddenField(String id, Class<T> type) 061 { 062 super(id, type); 063 } 064 065 /** 066 * Construct. 067 * 068 * @param id 069 * see Component 070 * @param model 071 * the model 072 */ 073 public HiddenField(String id, IModel<T> model) 074 { 075 super(id, model); 076 } 077 078 /** 079 * @param id 080 * component id 081 * @param model 082 * the model 083 * @param type 084 * the type to use when updating the model for this text field 085 * @see org.apache.wicket.Component#Component(String, IModel) 086 */ 087 public HiddenField(String id, IModel<T> model, Class<T> type) 088 { 089 super(id, model, type); 090 } 091 092 /** 093 * @see org.apache.wicket.markup.html.form.TextField#getInputTypes() 094 */ 095 @Override 096 protected String[] getInputTypes() 097 { 098 return new String[] {"hidden"}; 099 } 100}