org.wingx
Class XSuggest

java.lang.Object
  extended by org.wings.SComponent
      extended by org.wings.STextComponent
          extended by org.wings.STextField
              extended by org.wingx.XSuggest
All Implemented Interfaces:
Serializable, Cloneable, EventListener, SDocumentListener, LowLevelEventListener, Renderable, XSuggestDataSource

public class XSuggest
extends STextField
implements XSuggestDataSource

Enhanced STextField that supports the user input by displaying suggestions.

Author:
Christian Schyma
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.wingx.XSuggestDataSource
XSuggestDataSource.Entry
 
Field Summary
 
Fields inherited from class org.wings.STextField
actionCommand, columns, maxColumns
 
Fields inherited from class org.wings.SComponent
DONE_RENDERING, dynamicStyles, enabled, propertyChangeSupport, SELECTOR_ALL, START_RENDERING, visible, WHEN_FOCUSED_OR_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_IN_FOCUSED_FRAME
 
Constructor Summary
XSuggest()
          Creates a text field that can display suggestions.
XSuggest(String text)
          Creates a text field that can display suggestions.
 
Method Summary
 List<Map.Entry<String,String>> generateSuggestions(String lookupText)
          Obtaines the list of suggestions from the data source, if there is one.
 XSuggestDataSource getDataSource()
          returns the currently used data source
 int getInputDelay()
           
 SDimension getSuggestBoxWidth()
           
 int getTimeout()
           
 void processLowLevelEvent(String action, String[] values)
          Deliver low level/http events (parameters).
 void setDataSource(XSuggestDataSource source)
          set a new data source from which suggestions are generated
 void setInputDelay(int delay)
          Fast typists can produce a lot of requests in a short time; this delay limits the requests to a certain time.
 void setSuggestBoxWidth(SDimension dim)
          Configures the width of the suggest box.
 void setTimeout(int timeout)
          Set Ajax request timeout.
 
Methods inherited from class org.wings.STextField
addActionListener, fireActionEvent, fireActionPerformed, fireFinalEvents, getActionCommand, getActionListeners, getColumns, getMaxColumns, removeActionListener, setActionCommand, setCG, setColumns, setMaxColumns
 
Methods inherited from class org.wings.STextComponent
addDocumentListener, append, changedUpdate, fireIntermediateEvents, getDocument, getDocumentListeners, getText, insertUpdate, isEditable, isEpochCheckEnabled, removeDocumentListener, removeUpdate, setDocument, setEditable, setEpochCheckEnabled, setText
 
Methods inherited from class org.wings.SComponent
addComponentListener, addDynamicStyle, addEventListener, addNotify, addParentFrameListener, addPropertyChangeListener, addPropertyChangeListener, addRenderListener, addScriptListener, addStyle, clone, fireComponentChangeEvent, fireKeyEvents, fireRenderEvent, getActionMap, getBackground, getBorder, getCG, getClientProperty, getComponentPopupMenu, getDynamicStyle, getDynamicStyles, getFocusTraversalIndex, getFont, getForeground, getHorizontalAlignment, getInputMap, getInputMap, getListenerCount, getListenerList, getListeners, getLowLevelEventId, getName, getParent, getParentFrame, getPreferredSize, getRequestURL, getResidesInForm, getScriptListenerList, getScriptListeners, getSession, getShowAsFormComponent, getStyle, getToolTipText, getVerticalAlignment, invite, isDifferent, isEnabled, isFocusOwner, isRecursivelyVisible, isReloadForced, isUpdatePossible, isVisible, paramString, processComponentEvent, processKeyEvents, putClientProperty, reload, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, reloadIfChange, removeComponentListener, removeDynamicStyle, removeEventListener, removeNotify, removeParentFrameListener, removePropertyChangeListener, removePropertyChangeListener, removeRenderListener, removeScriptListener, removeStyle, requestFocus, scrollRectToVisible, setActionMap, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setBackground, setBorder, setCG, setComponentPopupMenu, setDynamicStyles, setEnabled, setFocusTraversalIndex, setFont, setForeground, setHorizontalAlignment, setInputMap, setInputMap, setName, setNameRaw, setParent, setParentFrame, setPreferredSize, setReloadForced, setShowAsFormComponent, setStyle, setToolTipText, setVerticalAlignment, setVisible, toString, update, updateCG, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.wings.LowLevelEventListener
getLowLevelEventId, getName, isEnabled
 

Constructor Detail

XSuggest

public XSuggest()
Creates a text field that can display suggestions.


XSuggest

public XSuggest(String text)
Creates a text field that can display suggestions.

Parameters:
text - initial content of the text field
Method Detail

setDataSource

public void setDataSource(XSuggestDataSource source)
set a new data source from which suggestions are generated

Parameters:
source -

getDataSource

public XSuggestDataSource getDataSource()
returns the currently used data source

See Also:
setDataSource(XSuggestDataSource source)

setTimeout

public void setTimeout(int timeout)
Set Ajax request timeout.

Parameters:
timeout - in ms

getTimeout

public int getTimeout()
See Also:
setTimeout(int timeout)

setInputDelay

public void setInputDelay(int delay)
Fast typists can produce a lot of requests in a short time; this delay limits the requests to a certain time.

Parameters:
delay - in ms

getInputDelay

public int getInputDelay()
See Also:
setInputDelay(int delay)

setSuggestBoxWidth

public void setSuggestBoxWidth(SDimension dim)
Configures the width of the suggest box. There are three possibilites:
- SDimension.AUTO automatically set the size in accordance to the content (default)
- SDimension.INHERIT inherits width from the suggest input box
- integer value

Parameters:
dim - width of suggest box, height is ignored

getSuggestBoxWidth

public SDimension getSuggestBoxWidth()

generateSuggestions

public List<Map.Entry<String,String>> generateSuggestions(String lookupText)
Obtaines the list of suggestions from the data source, if there is one.

Specified by:
generateSuggestions in interface XSuggestDataSource
Parameters:
lookupText -
Returns:
suggestions list with map entries or null, if there is no data source
See Also:
{org.wingx.XSuggestDataSource.generateSugestions()}

processLowLevelEvent

public void processLowLevelEvent(String action,
                                 String[] values)
Description copied from interface: LowLevelEventListener
Deliver low level/http events (parameters). The name-value-pairs of the HTTPRequest are considered low level events.

Specified by:
processLowLevelEvent in interface LowLevelEventListener
Overrides:
processLowLevelEvent in class STextComponent
Parameters:
action - the name-value-pair's name
values - the name-value-pair's values


wingS Swings ;-)