to.etc.domui.component.input
Class LookupInput<T>

java.lang.Object
  extended by to.etc.domui.dom.css.CssBase
      extended by to.etc.domui.dom.html.NodeBase
          extended by to.etc.domui.dom.html.NodeContainer
              extended by to.etc.domui.dom.html.Div
                  extended by to.etc.domui.component.input.LookupInput<T>
All Implemented Interfaces:
java.lang.Iterable<NodeBase>, IModelBinding, IBindable, INodeErrorDelegate, IActionControl, IControl<T>, IDisplayControl<T>, IHasChangeListener, IHasModifiedIndication, IInputNode<T>, IDraggable, IDropTargetable

public class LookupInput<T>
extends Div
implements IInputNode<T>, IHasModifiedIndication

Lookup input field component. Additional description on use of stylesheets: LookupInput can have this states:

Thing is that when LookupInput is selected (has value), it is rendered as table inside div. When we have readonly LookupInput, then we want only to override background color (not a border), so for that we have additional class =ui-lui-selected-ro. Unselected readonly LookupInput has only one TD in table, so there we can use simple ui-ro, since there we can set border (it would look ackward if we use style named ui-lui-selected-ro for unselected rendering).

Author:
Frits Jalvingh Created on Jun 1, 2008

Field Summary
static INodeContentRenderer<java.lang.Object> DEFAULT_RENDERER
           
 
Constructor Summary
LookupInput(java.lang.Class<T> lookupClass)
          Lookup a POJO Java bean persistent class.
LookupInput(java.lang.Class<T> lookupClass, ClassMetaModel metaModel)
           
LookupInput(java.lang.Class<T> lookupClass, java.lang.String[] resultColumns)
           
 
Method Summary
 void addKeywordProperty(java.lang.String name)
          Define a property to use for quick search.
 void addKeywordProperty(java.lang.String name, int minlen)
          Define a property to use for quick search.
 IBinder bind()
          Return the binder for this control.
 void createContent()
           
 TBody getBody()
           
 INodeContentRenderer<T> getContentRenderer()
           
 IErrorMessageListener getCustomErrorMessageListener()
           
 LookupForm<T> getExternalLookupForm()
           
 IActionAllowed getIsLookupAllowed()
           
 java.lang.String getKeySearchHint()
          Getter for keyword search hint.
 java.lang.String getKeyWordSearchCssClass()
           
 IKeyWordSearchQueryFactory<T> getKeyWordSearchHandler()
           
 java.lang.Class<T> getLookupClass()
           
 java.lang.String getLookupTitle()
          When set this defines the title of the lookup window.
 ClassMetaModel getMetaModel()
           
 IValueChanged<?> getOnValueChanged()
           
 IQueryHandler<T> getQueryHandler()
          The query handler to use, if a special one is needed.
 IQueryManipulator<T> getQueryManipulator()
          When set the specified manipulator will be called before a query is sent to the database.
 java.lang.String[] getResultColumns()
           
 java.util.List<SearchPropertyMetaModel> getSearchProperties()
          Set the list of lookup properties to use for lookup in the lookup form, when shown.
 Table getTable()
           
 T getValue()
          Returns the current value of this input component.
 T getValueSafe()
          Like IDisplayControl.getValue() this returns the value of the component, but this returns null if the value was invalid.
 boolean hasError()
          Return T if this node currently has an error associated with it.
 boolean isAllowEmptyQuery()
          When T the user can press search even when no criteria are entered.
 boolean isAllowKeyWordSearch()
          Getter for property m_allowKeyWordSearch.
 boolean isBound()
          Returns T if this control is bound to some data value.
 boolean isDisabled()
          Returns T if the control is currently in disabled.
 boolean isMandatory()
          Returns T if this control is a mandatory input.
 boolean isModified()
          Returns the modified-by-user flag.
 boolean isReadOnly()
          Returns T if the control is currently in readonly mode.
 void setAllowEmptyQuery(boolean allowEmptyQuery)
           
 void setAllowKeyWordSearch(boolean allowKeyWordSearch)
          Setter for property m_allowKeyWordSearch.
 void setContentRenderer(INodeContentRenderer<T> contentRenderer)
           
 void setCustomErrorMessageListener(IErrorMessageListener customErrorMessageListener)
           
 void setDisabled(boolean disabled)
          Set the input to disabled mode.
 void setExternalLookupForm(LookupForm<T> externalLookupForm)
           
 void setHint(java.lang.String text)
           
 void setIsLookupAllowed(IActionAllowed isLookupAllowed)
           
 void setKeySearchHint(java.lang.String keySearchHint)
          Set hint to keyword search input.
 void setKeyWordSearchCssClass(java.lang.String cssClass)
          Set custom css that would be applied only in case that component is rendering keyWordSearch.
 void setKeyWordSearchHandler(IKeyWordSearchQueryFactory<T> keyWordSearchManipulator)
           
 void setKeywordSearchProperties(java.util.List<SearchPropertyMetaModel> keywordLookupPropertyList)
           
 void setLookupTitle(java.lang.String lookupTitle)
          When set this defines the title of the lookup window.
 void setMandatory(boolean mandatory)
          Make the control mandatory.
 void setModified(boolean as)
          Set or clear the modified by user flag.
 void setOnValueChanged(IValueChanged<?> onValueChanged)
           
 void setQueryHandler(IQueryHandler<T> queryHandler)
           
 void setQueryManipulator(IQueryManipulator<T> queryManipulator)
          When set the specified manipulator will be called before a query is sent to the database.
 void setReadOnly(boolean readOnly)
          Sets the input to readonly-mode.
 void setResultColumns(java.lang.String[] resultColumns)
           
 void setSearchProperties(java.util.List<SearchPropertyMetaModel> searchPropertyList)
           
 void setValue(T v)
          Sets a new value.
 
Methods inherited from class to.etc.domui.dom.html.Div
afterCreateContent, componentHandleWebAction, fadeIn, fadeIn, fadeOut, getDragHandler, getDropBody, getDropHandler, getDropMode, getReturnPressed, setDragHandler, setDropBody, setDropHandler, setReturnPressed, slideDown, slideUp, tb, visit
 
Methods inherited from class to.etc.domui.dom.html.NodeContainer
add, add, add, addTable, canContain, delegateTo, findChildIndex, forceRebuild, getChild, getChildCount, getChildren, getDeepChild, getDeepChildren, getErrorFence, internalCheckNotDirty, internalClearDelta, internalClearDeltaFully, internalGetOldChildren, internalShelve, internalUnshelve, iterator, moveControlToModel, moveModelToControl, onRefresh, removeAllChildren, removeChild, removeChild, replaceChild, setControlsEnabled, setErrorFence, setErrorFence, setText, setValue
 
Methods inherited from class to.etc.domui.dom.html.NodeBase
$, acceptRequestParameter, addCssClass, addGlobalMessage, appendAfterMe, appendBeforeMe, appendCreateJS, appendJavascript, build, changed, clearFocusRequested, clearGlobalMessage, clearGlobalMessage, clearGlobalMessage, clearMessage, findComponentBundle, getActualID, getClicked, getComponentBundle, getCreateJS, getCssClass, getErrorDelegate, getErrorLocation, getMessage, getOnClickJS, getOnMouseDownJS, getPage, getParent, getParent, getParent, getSharedContext, getSpecialAttribute, getSpecialAttributeList, getTag, getTestID, getTitle, getUserObject, handleDrop, hasCssClass, internalGetOldParent, internalHasChangedAttributes, internalNeedClickHandler, internalOnClicked, internalSetHasChangedAttributes, internalSetHasChangedAttributes, internalSetTag, isBuilt, isFocusRequested, onAddedToPage, onBeforeFullRender, onForceRebuild, onHeaderContributors, onRemoveFromPage, onShelve, onUnshelve, refresh, remove, removeCssClass, renderJavascriptState, replaceWith, setClicked, setComponentBundle, setCssClass, setErrorDelegate, setErrorLocation, setFocus, setMessage, setOnClickJS, setOnMouseDownJS, setSpecialAttribute, setTestID, setTitle, setUserObject, stretchHeight, toString
 
Methods inherited from class to.etc.domui.dom.css.CssBase
getBackgroundAttachment, getBackgroundColor, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorderBottomColor, getBorderBottomStyle, getBorderBottomWidth, getBorderLeftColor, getBorderLeftStyle, getBorderLeftWidth, getBorderRightColor, getBorderRightStyle, getBorderRightWidth, getBorderTopColor, getBorderTopStyle, getBorderTopWidth, getBottom, getCachedStyle, getClear, getColor, getDisplay, getFloat, getFontFamily, getFontSize, getFontSizeAdjust, getFontStyle, getFontVariant, getFontWeight, getHeight, getLeft, getLineHeight, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOverflow, getPosition, getRight, getTextAlign, getTop, getTransform, getVerticalAlign, getVisibility, getWidth, getZIndex, internalSetDisplay, setBackgroundAttachment, setBackgroundColor, setBackgroundImage, setBackgroundPosition, setBackgroundRepeat, setBorder, setBorder, setBorderBottomColor, setBorderBottomStyle, setBorderBottomWidth, setBorderColor, setBorderLeftColor, setBorderLeftStyle, setBorderLeftWidth, setBorderRightColor, setBorderRightStyle, setBorderRightWidth, setBorderStyle, setBorderTopColor, setBorderTopStyle, setBorderTopWidth, setBorderWidth, setBottom, setBottom, setCachedStyle, setClear, setColor, setDisplay, setFloat, setFontFamily, setFontSize, setFontSizeAdjust, setFontStyle, setFontVariant, setFontWeight, setHeight, setLeft, setLeft, setLineHeight, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMarginTop, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setOverflow, setPosition, setRight, setRight, setTextAlign, setTop, setTop, setTransform, setVerticalAlign, setVisibility, setWidth, setZIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface to.etc.domui.dom.html.IControl
getErrorLocation, setErrorLocation
 
Methods inherited from interface to.etc.domui.dom.html.IDisplayControl
setTestID
 
Methods inherited from interface to.etc.domui.dom.html.IActionControl
setTestID
 
Methods inherited from interface to.etc.domui.dom.errors.INodeErrorDelegate
clearMessage, getMessage, setMessage
 

Field Detail

DEFAULT_RENDERER

public static final INodeContentRenderer<java.lang.Object> DEFAULT_RENDERER
Constructor Detail

LookupInput

public LookupInput(java.lang.Class<T> lookupClass,
                   java.lang.String[] resultColumns)

LookupInput

public LookupInput(java.lang.Class<T> lookupClass)
Lookup a POJO Java bean persistent class.

Parameters:
lookupClass -

LookupInput

public LookupInput(java.lang.Class<T> lookupClass,
                   ClassMetaModel metaModel)
Method Detail

getLookupClass

public java.lang.Class<T> getLookupClass()

getMetaModel

public ClassMetaModel getMetaModel()

getContentRenderer

public INodeContentRenderer<T> getContentRenderer()

setContentRenderer

public void setContentRenderer(INodeContentRenderer<T> contentRenderer)

createContent

public void createContent()
                   throws java.lang.Exception
Overrides:
createContent in class NodeBase
Throws:
java.lang.Exception

setHint

public void setHint(java.lang.String text)

isMandatory

public boolean isMandatory()
Description copied from interface: IControl
Returns T if this control is a mandatory input.

Specified by:
isMandatory in interface IControl<T>
Returns:

setMandatory

public void setMandatory(boolean mandatory)
Description copied from interface: IControl
Make the control mandatory.

Specified by:
setMandatory in interface IControl<T>

isReadOnly

public boolean isReadOnly()
Description copied from interface: IControl
Returns T if the control is currently in readonly mode. Controls that do not have a readonly ability (comboboxes) will use disabled as the readonly state. For those controls the readonly state mirrors the disabled state.

Specified by:
isReadOnly in interface IControl<T>
Returns:

setReadOnly

public void setReadOnly(boolean readOnly)
Description copied from interface: IControl
Sets the input to readonly-mode. Components that do not implement readonly mode (comboboxes) will usually set themselves to disabled which works much the same.

Specified by:
setReadOnly in interface IControl<T>

isDisabled

public boolean isDisabled()
Description copied from interface: IControl
Returns T if the control is currently in disabled. Controls that do not have a readonly ability (comboboxes) will use disabled as the readonly state. For those controls the readonly state mirrors the disabled state.

Specified by:
isDisabled in interface IControl<T>
Returns:

setDisabled

public void setDisabled(boolean disabled)
Description copied from interface: IActionControl
Set the input to disabled mode.

Specified by:
setDisabled in interface IActionControl

getValue

public T getValue()
Description copied from interface: IDisplayControl
Returns the current value of this input component. If the component contains no value this returns null. All text input components will return null when their value is the empty string! If the component, during conversion or validation of the input value, discovers that the input is invalid it will set itself in "error" mode, post an error message up the form, and throw a ValidationException. This means that this call either delivers correct input (as defined by it's converter and validators), null (when empty) or throws an exception. When a ValidationException occurs the framework mostly ignores it - it does not produce a stacktrace or error in the client. Instead the resulting error as posted by the error handling framework gets displayed on the form when the request completes.

To get the value of a component while ignoring exceptions call #getValueSafe().

Specified by:
getValue in interface IDisplayControl<T>
Returns:
See Also:
IDisplayControl.getValue()

getValueSafe

public T getValueSafe()
Description copied from interface: IControl
Like IDisplayControl.getValue() this returns the value of the component, but this returns null if the value was invalid. For this method NULL either means the value was invalid OR it's content was empty. To distinguish between the two call IControl.hasError() or use IDisplayControl.getValue() instead of this call.

Specified by:
getValueSafe in interface IControl<T>
Returns:
See Also:
IControl.getValueSafe()

hasError

public boolean hasError()
Description copied from class: NodeBase
Return T if this node currently has an error associated with it.

Specified by:
hasError in interface IControl<T>
Overrides:
hasError in class NodeBase
Returns:
See Also:
IControl.hasError()

setValue

public void setValue(T v)
Sets a new value. This re-renders the entire control's contents always.

Specified by:
setValue in interface IDisplayControl<T>
See Also:
IDisplayControl.setValue(java.lang.Object)

getOnValueChanged

public IValueChanged<?> getOnValueChanged()
Specified by:
getOnValueChanged in interface IHasChangeListener
See Also:
IHasChangeListener.getOnValueChanged()

setOnValueChanged

public void setOnValueChanged(IValueChanged<?> onValueChanged)
Specified by:
setOnValueChanged in interface IHasChangeListener
See Also:
IHasChangeListener.setOnValueChanged(to.etc.domui.dom.html.IValueChanged)

getQueryManipulator

public IQueryManipulator<T> getQueryManipulator()
When set the specified manipulator will be called before a query is sent to the database. The query can be altered to add extra restrictions for instance.

Returns:

getQueryHandler

public IQueryHandler<T> getQueryHandler()
The query handler to use, if a special one is needed. The default query handler will use the normal conversation-associated DataContext to issue the query.

Returns:

setQueryHandler

public void setQueryHandler(IQueryHandler<T> queryHandler)

getLookupTitle

public java.lang.String getLookupTitle()
When set this defines the title of the lookup window.

Returns:

setLookupTitle

public void setLookupTitle(java.lang.String lookupTitle)
When set this defines the title of the lookup window.

Parameters:
lookupTitle -

isAllowEmptyQuery

public boolean isAllowEmptyQuery()
When T the user can press search even when no criteria are entered.

Returns:

setAllowEmptyQuery

public void setAllowEmptyQuery(boolean allowEmptyQuery)

setQueryManipulator

public void setQueryManipulator(IQueryManipulator<T> queryManipulator)
When set the specified manipulator will be called before a query is sent to the database. The query can be altered to add extra restrictions for instance.

Parameters:
queryManipulator -

getExternalLookupForm

public LookupForm<T> getExternalLookupForm()

setExternalLookupForm

public void setExternalLookupForm(LookupForm<T> externalLookupForm)

getResultColumns

public java.lang.String[] getResultColumns()

setResultColumns

public void setResultColumns(java.lang.String[] resultColumns)

getCustomErrorMessageListener

public IErrorMessageListener getCustomErrorMessageListener()

setCustomErrorMessageListener

public void setCustomErrorMessageListener(IErrorMessageListener customErrorMessageListener)

isModified

public boolean isModified()
Returns the modified-by-user flag.

Specified by:
isModified in interface IHasModifiedIndication
See Also:
IHasModifiedIndication.isModified()

setModified

public void setModified(boolean as)
Set or clear the modified by user flag.

Specified by:
setModified in interface IHasModifiedIndication
See Also:
IHasModifiedIndication.setModified(boolean)

bind

public IBinder bind()
Return the binder for this control.

Specified by:
bind in interface IBindable
Returns:
See Also:
IBindable.bind()

isBound

public boolean isBound()
Returns T if this control is bound to some data value.

Specified by:
isBound in interface IBindable
Returns:
See Also:
IBindable.isBound()

getIsLookupAllowed

public IActionAllowed getIsLookupAllowed()

setIsLookupAllowed

public void setIsLookupAllowed(IActionAllowed isLookupAllowed)

getKeyWordSearchHandler

public IKeyWordSearchQueryFactory<T> getKeyWordSearchHandler()

setKeyWordSearchHandler

public void setKeyWordSearchHandler(IKeyWordSearchQueryFactory<T> keyWordSearchManipulator)

getKeyWordSearchCssClass

public java.lang.String getKeyWordSearchCssClass()

setKeyWordSearchCssClass

public void setKeyWordSearchCssClass(java.lang.String cssClass)
Set custom css that would be applied only in case that component is rendering keyWordSearch. Used for example in row inline rendering, where width and min-width should be additionaly customized.

Parameters:
cssClass -

isAllowKeyWordSearch

public boolean isAllowKeyWordSearch()
Getter for property m_allowKeyWordSearch.

Returns:

setAllowKeyWordSearch

public void setAllowKeyWordSearch(boolean allowKeyWordSearch)
Setter for property m_allowKeyWordSearch.


getKeySearchHint

public java.lang.String getKeySearchHint()
Getter for keyword search hint. See setKeySearchHint(java.lang.String).

Parameters:
hint -

setKeySearchHint

public void setKeySearchHint(java.lang.String keySearchHint)
Set hint to keyword search input. Usually says how search condition is resolved.

Parameters:
hint -

addKeywordProperty

public void addKeywordProperty(java.lang.String name,
                               int minlen)
Define a property to use for quick search. When used this overrides any metadata-defined properties.

Parameters:
name -
minlen -

setKeywordSearchProperties

public void setKeywordSearchProperties(java.util.List<SearchPropertyMetaModel> keywordLookupPropertyList)

getSearchProperties

public java.util.List<SearchPropertyMetaModel> getSearchProperties()
Set the list of lookup properties to use for lookup in the lookup form, when shown.

Returns:

setSearchProperties

public void setSearchProperties(java.util.List<SearchPropertyMetaModel> searchPropertyList)

addKeywordProperty

public void addKeywordProperty(java.lang.String name)
Define a property to use for quick search. When used this overrides any metadata-defined properties.

Parameters:
name -

getTable

public Table getTable()

getBody

public TBody getBody()