⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstracttextcomponent.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
字号:
/* * 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.apache.wicket.markup.html.form;import java.text.SimpleDateFormat;import org.apache.wicket.Component;import org.apache.wicket.model.IModel;import org.apache.wicket.model.IObjectClassAwareModel;import org.apache.wicket.util.convert.ConversionException;import org.apache.wicket.util.string.Strings;/** * Abstract base class for TextArea and TextField. *  * @author Jonathan Locke */public abstract class AbstractTextComponent extends FormComponent{	// Flag for the type resolving. FLAG_RESERVED1-3 is taken by form component	private static final int TYPE_RESOLVED = Component.FLAG_RESERVED4;	/**	 * 	 */	private static final long serialVersionUID = 1L;	/**	 * Text components that implement this interface are know to be able to provide a pattern for	 * formatting output and parsing input. This can be used by for instance date picker components	 * which are based on Javascript and need some knowledge as to how to communicate properly via	 * request parameters.	 */	public static interface ITextFormatProvider	{		/**		 * Gets the pattern for printing output and parsing input.		 * 		 * @return The text pattern		 * @see SimpleDateFormat		 */		String getTextFormat();	}	/**	 * @see org.apache.wicket.Component#Component(String)	 */	public AbstractTextComponent(String id)	{		super(id);		setConvertEmptyInputStringToNull(true);	}	/**	 * @see org.apache.wicket.Component#Component(String, IModel)	 */	public AbstractTextComponent(final String id, final IModel model)	{		super(id, model);		setConvertEmptyInputStringToNull(true);	}	/**	 * Should the bound object become <code>null</code> when the input is empty?	 * 	 * @return <code>true</code> when the value will be set to <code>null</code> when the input	 *         is empty.	 */	public final boolean getConvertEmptyInputStringToNull()	{		return getFlag(FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL);	}	/**	 * TextFields return an empty string even if the user didn't type anything in them. To be able	 * to work nicely with validation, this method returns false.	 * 	 * @see org.apache.wicket.markup.html.form.FormComponent#isInputNullable()	 */	public boolean isInputNullable()	{		return false;	}	/**	 * If the type is not set try to guess it if the model supports it.	 * 	 * @see org.apache.wicket.Component#onBeforeRender()	 */	protected void onBeforeRender()	{		super.onBeforeRender();		if (!getFlag(TYPE_RESOLVED) && getType() == null)		{			// Set the type, but only if it's not a String (see WICKET-606).			// Otherwise, getConvertEmptyInputStringToNull() won't work.			Class type = getModelType(getModel());			if (!String.class.equals(type))			{				setType(type);			}			setFlag(TYPE_RESOLVED, true);		}	}	private Class getModelType(IModel model)	{		if (model instanceof IObjectClassAwareModel)		{			return ((IObjectClassAwareModel)model).getObjectClass();		}		else		{			return null;		}	}	/**	 * Should the bound object become <code>null</code> when the input is empty?	 * 	 * @param flag	 *            the value to set this flag.	 * @return this	 */	public final FormComponent setConvertEmptyInputStringToNull(boolean flag)	{		setFlag(FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, flag);		return this;	}	/**	 * @see org.apache.wicket.markup.html.form.FormComponent#convertValue(String[])	 */	protected Object convertValue(String[] value) throws ConversionException	{		String tmp = value != null && value.length > 0 ? value[0] : null;		if (getConvertEmptyInputStringToNull() && Strings.isEmpty(tmp))		{			return null;		}		return super.convertValue(value);	}	/**	 * @see FormComponent#supportsPersistence()	 */	protected boolean supportsPersistence()	{		return true;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -