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.extensions.ajax.markup.html.autocomplete;
 
 
An implementation of a textfield with the autoassist ajax behavior AutoCompleteBehavior. FIXME javadoc - constructors need proper descriptions Note that you must add your own CSS to make the suggestion display properly, see DefaultCssAutocompleteTextField for an example.

Parameters:
<T> The model object type
Author(s):
Igor Vaynberg (ivaynberg)
Since:
1.2
See also:
DefaultCssAutocompleteTextField
AutoCompleteBehavior
IAutoCompleteRenderer
 
 public abstract class AutoCompleteTextField<T> extends TextField<T>
 {
 
 	private static final long serialVersionUID = 1L;

auto complete behavior attached to this textfield
 
renderer
 
 	private final IAutoCompleteRenderer<T> renderer;

settings
 
 	private final AutoCompleteSettings settings;


Parameters:
id
type
 
 	public AutoCompleteTextField(String idClass<T> type)
 	{
 		this(id, (IModel<T>)nulltypenew AutoCompleteSettings());
 	}

 
 	public AutoCompleteTextField(String idIModel<T> modelClass<T> typeboolean preselect)
 	{
 		this(idmodeltype.,
 			new AutoCompleteSettings().setPreselect(preselect));
 	}

Construct.

Parameters:
id
model
type
settings
 
 	public AutoCompleteTextField(String idIModel<T> modelClass<T> type,
 	{
 		this(idmodeltype.settings);
 	}

	public AutoCompleteTextField(String idIModel<T> objectboolean preselect)
	{
		this(idobject, (Class<T>)nullnew AutoCompleteSettings().setPreselect(preselect));
	}

Construct.

Parameters:
id
object
settings
	public AutoCompleteTextField(String idIModel<T> objectAutoCompleteSettings settings)
	{
		this(idobject, (Class<T>)nullsettings);
	}


Parameters:
id
object
	public AutoCompleteTextField(String idIModel<T> object)
	{
		this(idobject, (Class<T>)nullnew AutoCompleteSettings());
	}

	public AutoCompleteTextField(String idboolean preselect)
	{
		this(id, (IModel<T>)nullnew AutoCompleteSettings().setPreselect(preselect));
	}

Construct.

Parameters:
id
settings
	{
		this(id, (IModel<T>)nullsettings);
	}

Parameters:
id
	{
		this(id, (IModel<T>)nullnew AutoCompleteSettings());
	}

Parameters:
id
renderer
	{
		this(id, (IModel<T>)nullrenderer);
	}

Parameters:
id
type
renderer
	public AutoCompleteTextField(String idClass<T> typeIAutoCompleteRenderer<T> renderer)
	{
		this(idnulltyperenderernew AutoCompleteSettings());
	}

Parameters:
id
model
renderer
	public AutoCompleteTextField(String idIModel<T> modelIAutoCompleteRenderer<T> renderer)
	{
		this(idmodel, (Class<T>)nullrenderernew AutoCompleteSettings());
	}

	public AutoCompleteTextField(String idIModel<T> modelClass<T> type,
		IAutoCompleteRenderer<T> rendererboolean preselect)
	{
		this(idmodeltyperenderernew AutoCompleteSettings().setPreselect(preselect));
	}

Construct.

Parameters:
id
model
type
renderer
settings
	public AutoCompleteTextField(String idIModel<T> modelClass<T> type,
	{
		super(idmodeltype);
		this. = renderer;
		this. = settings;
	}


Factory method for autocomplete behavior that will be added to this textfield

Parameters:
renderer auto complete renderer
settings auto complete settings
Returns:
auto complete behavior
	{
		return new AutoCompleteBehavior<T>(renderersettings)
		{
			private static final long serialVersionUID = 1L;
			protected Iterator<T> getChoices(String input)
			{
				return AutoCompleteTextField.this.getChoices(input);
			}
		};
	}

	protected void onBeforeRender()
	{
		// add auto complete behavior to this component if its not already there
		if ( == null)
		{
			// we do this here instad of constructor so we can have an overridable factory method
		}
	}

	protected void onComponentTag(ComponentTag tag)
	{
		super.onComponentTag(tag);
		// disable browser's autocomplete
		tag.put("autocomplete""off");
	}

Callback method that should return an iterator over all possible assist choice objects. These objects will be passed to the renderer to generate output. Usually it is enough to return an iterator over strings.

Parameters:
input current input
Returns:
iterator over all possible choice objects
See also:
AutoCompleteBehavior.getChoices(java.lang.String)
	protected abstract Iterator<T> getChoices(String input);
New to GrepCode? Check out our FAQ X