Spiffy UI Framework

org.spiffyui.client.widgets.multivaluesuggest
Class MultivalueSuggestBoxBase

java.lang.Object
  extended by Composite
      extended by org.spiffyui.client.widgets.multivaluesuggest.MultivalueSuggestBoxBase
Direct Known Subclasses:
MultivalueSuggestBox

public abstract class MultivalueSuggestBoxBase
extends Composite

A SuggestBox that allows for multiple values selection and autocomplete.


Nested Class Summary
 class MultivalueSuggestBoxBase.Option
          Bean for name-value pairs
protected  class MultivalueSuggestBoxBase.OptionResultSet
          Bean for total size and options
 class MultivalueSuggestBoxBase.OptionSuggestion
          A bean to serve as a custom suggestion so that the value is available and the replace will look like it is supporting multivalues
 class MultivalueSuggestBoxBase.RestSuggestCallback
          A custom callback that has the original SuggestOracle.Request and SuggestOracle.Callback
 class MultivalueSuggestBoxBase.RestSuggestOracle
          A custom Suggest Oracle
 class MultivalueSuggestBoxBase.SelectedItem
          This class represents a UI element for a selected item.
 
Constructor Summary
MultivalueSuggestBoxBase(MultivalueSuggestHelper restHelper, boolean isMultivalued)
          Constructor that will place the FormFeedback for you.
MultivalueSuggestBoxBase(MultivalueSuggestHelper helper, boolean isMultivalued, boolean placeFormFeedback)
          Constructor.
 
Method Summary
 HandlerRegistration addKeyUpHandler(KeyUpHandler handler)
          Add a KeyUpHandler to the suggest box
 void addSelectedOption(MultivalueSuggestBoxBase.Option option)
          This only applies when allowing multivalues.
 HandlerRegistration addValueChangeHandler( handler)
           
protected  MultivalueSuggestBoxBase.Option createOption(JSONObject jsonOpt)
          Create and return a new Option with fields populated
protected  MultivalueSuggestBoxBase.OptionSuggestion createOptionSuggestion(MultivalueSuggestBoxBase.Option o, java.lang.String fullText, java.lang.String query)
          Create and return a new OptionSuggestion with fields populated
protected  MultivalueSuggestBoxBase.SelectedItem createSelectedItem(MultivalueSuggestBoxBase.Option option)
          Create and return a SelectedItem populated with the option
 FormFeedback getFeedback()
          Get the FormFeedback widget used.
protected  MultivalueSuggestHelper getHelper()
          Get the suggest helper for this suggest box.
 java.lang.String getInvalidReason(java.lang.String invalids, java.lang.String reason)
          Get the parameterized localized String for invalid values.
 java.lang.String getInvalidText(java.lang.String invalids)
          Get the parameterized localized String for invalid values.
 java.lang.String getSelectedItemEq()
           
 java.util.List<MultivalueSuggestBoxBase.Option> getSelectedOptions()
          Get the Options that were selected
 SuggestBox getSuggestBox()
          Gets the SuggestBox field
 java.lang.String getSuggestBoxContainerId()
          Get the ID of the suggest box container.
 int getTabIndex()
           
 java.lang.String getText()
          Gets the text within the text field of the suggest box
 java.lang.String getValue()
          Get the value(s) as a String.
 java.util.Map<java.lang.String,java.lang.String> getValueMap()
          Get the value map
 java.lang.String getValuesAsString()
          Get the text and values combined as a string with each selected item starting with m_selectedItemStart and ending with m_selectedItemEnd, and the display text and value separated by m_selectedItemEq
protected  void handleQueryResponse(RESTObjectCallBack<MultivalueSuggestBoxBase.OptionResultSet> callback, JSONValue val)
          Handle the query response for getting items to suggest.
 void onKeyUp(KeyUpEvent event)
           
 void onLoad()
           
 void onSelection( event)
           
protected abstract  void queryOptions(java.lang.String query, int from, int to, RESTObjectCallBack<MultivalueSuggestBoxBase.OptionResultSet> callback)
          Retrieve Options (name-value pairs) that are suggested
 void setAccessKey(char key)
           
 void setDelay(int delay)
          Set the time in milliseconds a user should stop typing before a query to the server is sent.
 void setDisplaySeparator(java.lang.String displaySeparator)
          Set the delimiting character(s) between the display texts.
 void setFeedback(FormFeedback feedback)
          Set the FormFeedback widget used.
 void setFocus(boolean focused)
           
 void setLoadingText(java.lang.String loadingText)
          Sets the loading text String
 void setPageSize(int pageSize)
          Set the maximum number of options in the selection dropdown list at a time.
 void setSelectedItemEq(java.lang.String selectedItemEq)
           
 void setSelectedOptions(java.util.List<MultivalueSuggestBoxBase.Option> options)
          This only applies when allowing multivalues.
 void setTabIndex(int index)
           
 void setText(java.lang.String text)
          Sets the text within the text field of the suggest box
 void setValidText(java.lang.String validText)
          Sets the valid text String.
 void setValueDelim(java.lang.String valueDelim)
          Set the delimiting character(s) between values if calling getValue to get all the values in the value map as a single String.
 void setValueMap(java.util.Map<java.lang.String,java.lang.String> valueMap)
          Call this method to set the default values.
 void setValuesAsString(java.lang.String text)
          Set the text of this compound search box
 void updateFormFeedback(int status, java.lang.String tooltip)
          Convenience method to set the status and tooltip of the FormFeedback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultivalueSuggestBoxBase

public MultivalueSuggestBoxBase(MultivalueSuggestHelper restHelper,
                                boolean isMultivalued)
Constructor that will place the FormFeedback for you.

Parameters:
restHelper - the REST helper for getting remote values for this suggest box
isMultivalued - whether or not to allow multiple values

MultivalueSuggestBoxBase

public MultivalueSuggestBoxBase(MultivalueSuggestHelper helper,
                                boolean isMultivalued,
                                boolean placeFormFeedback)
Constructor.

Parameters:
helper - - a MultivalueSuggestHelper object
isMultivalued - - whether or not to allow multiple values
placeFormFeedback - - if false, the FormFeedback will be placed by the calling class
Method Detail

getSuggestBoxContainerId

public java.lang.String getSuggestBoxContainerId()
Get the ID of the suggest box container.

Returns:
the container ID

onLoad

public void onLoad()

getHelper

protected MultivalueSuggestHelper getHelper()
Get the suggest helper for this suggest box.

Returns:
the suggest helper

updateFormFeedback

public void updateFormFeedback(int status,
                               java.lang.String tooltip)
Convenience method to set the status and tooltip of the FormFeedback

Parameters:
status - - a FormFeedback status
tooltip - - a String tooltip

getValue

public java.lang.String getValue()
Get the value(s) as a String. If allowing multivalues, separated by the VALUE_DELIM. This is different from getValuesAsString, which includes the display text as well.

Returns:
value(s) as a String

getValuesAsString

public java.lang.String getValuesAsString()
Get the text and values combined as a string with each selected item starting with m_selectedItemStart and ending with m_selectedItemEnd, and the display text and value separated by m_selectedItemEq

Returns:
the text representation of all the selected items

getValueMap

public java.util.Map<java.lang.String,java.lang.String> getValueMap()
Get the value map

Returns:
value map

getSelectedOptions

public java.util.List<MultivalueSuggestBoxBase.Option> getSelectedOptions()
Get the Options that were selected

Returns:
Returns the List of selected Option beans.

addSelectedOption

public void addSelectedOption(MultivalueSuggestBoxBase.Option option)
This only applies when allowing multivalues. If single-valued, then this does nothing. (For single-valued, use setValueMap or setValuesAsString.)

Parameters:
option - - the Option to add

setSelectedOptions

public void setSelectedOptions(java.util.List<MultivalueSuggestBoxBase.Option> options)
This only applies when allowing multivalues. If single-valued, then this method does nothing. (For single-valued, use setValueMap or setValuesAsString.)

Parameters:
options - - List of Option beans

setValueMap

public void setValueMap(java.util.Map<java.lang.String,java.lang.String> valueMap)
Call this method to set the default values. If it is multi-valued, SelectedItems will be added for each entry. Note: only Option base class will be used for SelectedItem objects. To add SelectedItems with descendant of Option, use addSelectedOption or setSelectedOptions

Parameters:
valueMap - the valueMap to set

setValuesAsString

public void setValuesAsString(java.lang.String text)
Set the text of this compound search box

Parameters:
text - the text to use

createSelectedItem

protected MultivalueSuggestBoxBase.SelectedItem createSelectedItem(MultivalueSuggestBoxBase.Option option)
Create and return a SelectedItem populated with the option

Parameters:
option - - an Option bean
Returns:
the SelectedItem to be pushed

createOption

protected MultivalueSuggestBoxBase.Option createOption(JSONObject jsonOpt)
Create and return a new Option with fields populated

Parameters:
jsonOpt - - the JSONObject to populate Option
Returns:
a populated Option

createOptionSuggestion

protected MultivalueSuggestBoxBase.OptionSuggestion createOptionSuggestion(MultivalueSuggestBoxBase.Option o,
                                                                           java.lang.String fullText,
                                                                           java.lang.String query)
Create and return a new OptionSuggestion with fields populated

Parameters:
o - - the Option to get values to populate the OptionSuggestion
fullText - - the full text in the text field of the suggest box
query - - the query portion of the full text
Returns:
a populated OptionSuggestion

onSelection

public void onSelection( event)

getSuggestBox

public SuggestBox getSuggestBox()
Gets the SuggestBox field

Returns:
the SuggestBox component

getText

public java.lang.String getText()
Gets the text within the text field of the suggest box

Returns:
display text

setText

public void setText(java.lang.String text)
Sets the text within the text field of the suggest box

Parameters:
text - to set

getTabIndex

public int getTabIndex()

setAccessKey

public void setAccessKey(char key)

setFocus

public void setFocus(boolean focused)

setTabIndex

public void setTabIndex(int index)

addKeyUpHandler

public HandlerRegistration addKeyUpHandler(KeyUpHandler handler)
Add a KeyUpHandler to the suggest box

Parameters:
handler - to add
Returns:
the HandlerRegistration

addValueChangeHandler

public HandlerRegistration addValueChangeHandler( handler)

onKeyUp

public void onKeyUp(KeyUpEvent event)

getSelectedItemEq

public java.lang.String getSelectedItemEq()
Returns:
Returns the selectedItemEq.

setSelectedItemEq

public void setSelectedItemEq(java.lang.String selectedItemEq)
Parameters:
selectedItemEq - The selectedItemEq to set.

setDisplaySeparator

public void setDisplaySeparator(java.lang.String displaySeparator)
Set the delimiting character(s) between the display texts. If the display separator includes white space, it is automatically included for display, but is trimmed when getting values.

Parameters:
displaySeparator - The displaySeparator to set.

setValueDelim

public void setValueDelim(java.lang.String valueDelim)
Set the delimiting character(s) between values if calling getValue to get all the values in the value map as a single String.

Parameters:
valueDelim - The valueDelim to set.

setPageSize

public void setPageSize(int pageSize)
Set the maximum number of options in the selection dropdown list at a time. This is used to send URL parameters of indexFrom and indexTo to the REST endpoint.

Parameters:
pageSize - The pageSize to set.

setDelay

public void setDelay(int delay)
Set the time in milliseconds a user should stop typing before a query to the server is sent.

Parameters:
delay - The delay to set.

getFeedback

public FormFeedback getFeedback()
Get the FormFeedback widget used.

Returns:
Returns the feedback.

setFeedback

public void setFeedback(FormFeedback feedback)
Set the FormFeedback widget used.

Parameters:
feedback - The feedback to set.

getInvalidText

public java.lang.String getInvalidText(java.lang.String invalids)
Get the parameterized localized String for invalid values. This is the method to override with custom localization methods.

Parameters:
invalids - - the value or values that are invalid.
Returns:
Returns the invalidText.

getInvalidReason

public java.lang.String getInvalidReason(java.lang.String invalids,
                                         java.lang.String reason)
Get the parameterized localized String for invalid values. This is the method to override with custom localization methods.

Parameters:
invalids - - the value or values that are invalid.
reason - - the reason or message returned about the invalid value
Returns:
Returns the invalidText.

setValidText

public void setValidText(java.lang.String validText)
Sets the valid text String.

Parameters:
validText - The validText to set.

setLoadingText

public void setLoadingText(java.lang.String loadingText)
Sets the loading text String

Parameters:
loadingText - The loadingText to set.

queryOptions

protected abstract void queryOptions(java.lang.String query,
                                     int from,
                                     int to,
                                     RESTObjectCallBack<MultivalueSuggestBoxBase.OptionResultSet> callback)
Retrieve Options (name-value pairs) that are suggested

Parameters:
query - - the String search term
from - - the 0-based begin index int
to - - the end index inclusive int
callback - - the RESTObjectCallBack to handle the response

handleQueryResponse

protected void handleQueryResponse(RESTObjectCallBack<MultivalueSuggestBoxBase.OptionResultSet> callback,
                                   JSONValue val)
Handle the query response for getting items to suggest.

Parameters:
callback - the callback for the request
val - the value we are getting suggestions for

Spiffy UI Framework