001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018
019 package echopoint;
020
021 import echopoint.internal.TextField;
022
023 /**
024 * The {@code KeystrokeTextField} allows you to be notified about each keystroke
025 * in the text field component.
026 * This can for example be used to do a incremental filetring of a server
027 * database and then display the matching records as you type.
028 *
029 * Please use the following component with care, it creates a request for every
030 * keystroke per default. You can configure a keystrokeDelay which synchronizes
031 * only after the specified delay. So someone who is typing rapidly doesn't
032 * create lots of requests, instead the synchronization is triggered only when
033 * the user stops typing for the specified amount of time (=keystrokeDelay).
034 *
035 * @author André Schild, 299-06-05, Based on code posted in the Echo wiki
036 * @version $Id: $
037 */
038 public class KeystrokeTextField extends TextField
039 {
040 private static final long serialVersionUID = 1l;
041
042 /**
043 */
044 public static final String PROPERTY_KEYSTROKE_DELAY = "keystrokeDelay";
045
046 /**
047 * Default constructor.
048 * Uses a keystroke delay of 0ms. Not a good idea in most cases. Instead
049 * use the constructor with a keystrokeDelay of for example 250ms
050 *
051 */
052 public KeystrokeTextField() {}
053
054 /**
055 * Create a new text field with the specified keystroke delay
056 *
057 * @param keystrokeDelay The keystroke delay to be used in ms
058 */
059 public KeystrokeTextField( final int keystrokeDelay )
060 {
061 setKeystrokeDelay( keystrokeDelay );
062 }
063
064 /**
065 * Set the keystroke delay
066 *
067 * @param keystrokeDelay The keystroke delay to be used in ms
068 */
069 public void setKeystrokeDelay( final int keystrokeDelay )
070 {
071 set( PROPERTY_KEYSTROKE_DELAY, keystrokeDelay );
072 }
073 }
074