Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 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;
 
 
Abstract base class for TextArea and TextField.

Author(s):
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 = .;

 
 	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.

Returns:
The text pattern
See also:
java.text.SimpleDateFormat
 
 	}

See also:
org.apache.wicket.Component.org.apache.wicket.Component.(java.lang.String)
 
 	{
 		super(id);
 	}

 
 	public AbstractTextComponent(final String idfinal IModel model)
 	{
 		super(idmodel);
 	}

Should the bound object become null when the input is empty?

Returns:
true when the value will be set to null when the input is empty.
 
 	public final boolean getConvertEmptyInputStringToNull()
 	{
 	}

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.

 
 	public boolean isInputNullable()
 	{
 		return false;
 	}


If the type is not set try to guess it if the model supports it.

	protected void onBeforeRender()
	{
		if (!getFlag() && getType() == null)
		{
			// Set the type, but only if it's not a String (see WICKET-606).
			// Otherwise, getConvertEmptyInputStringToNull() won't work.
			if (!String.class.equals(type))
			{
				setType(type);
			}
		}
	}
	private Class getModelType(IModel model)
	{
		if (model instanceof IObjectClassAwareModel)
		{
		}
		else
		{
			return null;
		}
	}

Should the bound object become null when the input is empty?

Parameters:
flag the value to set this flag.
Returns:
this
	public final FormComponent setConvertEmptyInputStringToNull(boolean flag)
	{
		return this;
	}

	protected Object convertValue(String[] valuethrows ConversionException
	{
		String tmp = value != null && value.length > 0 ? value[0] : null;
		if (getConvertEmptyInputStringToNull() && Strings.isEmpty(tmp))
		{
			return null;
		}
		return super.convertValue(value);
	}

	protected boolean supportsPersistence()
	{
		return true;
	}
New to GrepCode? Check out our FAQ X