Class LookupTextField

java.lang.Object
org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.impl.XulElement
org.zkoss.zul.impl.InputElement
org.zkoss.zul.Textbox
org.zkoss.zul.Bandbox
com.saperion.ngc.iform.field.LookupTextField
All Implemented Interfaces:
EventChild, IntelligentField, LookupField, Localized, Identifiable, Serializable, Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.ext.Disable, org.zkoss.zk.ui.ext.Readonly, org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.sys.ComponentCtrl, org.zkoss.zul.ext.Constrainted

public class LookupTextField extends org.zkoss.zul.Bandbox implements IntelligentField, Identifiable, LookupField
This field is used for two purposes:

1) A textbox with a popup used to display the values of a lookup-table. Once the user selected an entry in the result list in the popup, the properties of the selected row are stored in an attribute named "selectedRow". Additionally an event named "onLookupSelected" containing the current selection is fired.

2) A textbox with a popup containing a fixed set of predefined values. The user is able to select any number of these values by checking the rows in the list with the items. This functionality is enabled by setting a value for "Form" and removing the checkmark from "Show Buttons" in the forms-designer. The predefined values entered in "Form" can be replaced with other values by using the setMultiSearchItems method.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • open

      public void open()
      Overrides:
      open in class org.zkoss.zul.Bandbox
      See Also:
      • Bandbox.open()
    • onOpen

      public void onOpen(org.zkoss.zk.ui.event.Event event)
      Parameters:
      event - Open event
    • onCreate

      public void onCreate(org.zkoss.zk.ui.event.Event event)
      Parameters:
      event - Create event.
    • onChange

      public void onChange(org.zkoss.zk.ui.event.Event event)
      Parameters:
      event - Change event.
    • onOK

      public void onOK(org.zkoss.zk.ui.event.Event event)
      Parameters:
      event - OK event.
    • onPageAttached

      public void onPageAttached(org.zkoss.zk.ui.Page newPage, org.zkoss.zk.ui.Page oldPage)
      Specified by:
      onPageAttached in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      onPageAttached in class org.zkoss.zk.ui.AbstractComponent
      See Also:
      • AbstractComponent.onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page)
    • onPageDetached

      public void onPageDetached(org.zkoss.zk.ui.Page page)
      Specified by:
      onPageDetached in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      onPageDetached in class org.zkoss.zk.ui.AbstractComponent
      See Also:
      • AbstractComponent.onPageDetached(org.zkoss.zk.ui.Page)
    • onIndexChange

      public void onIndexChange(org.zkoss.zk.ui.event.Event event)
      Event handler for index changes.
      Specified by:
      onIndexChange in interface IntelligentField
      Parameters:
      event - Event
      See Also:
    • onVariablesAvailable

      public void onVariablesAvailable(org.zkoss.zk.ui.event.Event event)
      Event handler for variablesAvailableEvent. The event-object sent does not contain data. To retrieve variables, use IntelligentFormView.getIndexMaskDocument().
      Specified by:
      onVariablesAvailable in interface IntelligentField
      Parameters:
      event - Event
      See Also:
    • onCancelEdit

      public void onCancelEdit(org.zkoss.zk.ui.event.Event event)
      Event handler for cancel edit event.
      Specified by:
      onCancelEdit in interface IntelligentField
      Parameters:
      event - event
      See Also:
    • setValue

      public void setValue(com.saperion.intf.SaPropertyValue val)
      Sets the value of this field.
      Specified by:
      setValue in interface IntelligentField
      Parameters:
      val - value
      See Also:
    • getPropertyValue

      public com.saperion.intf.SaPropertyValue getPropertyValue()
      Description copied from interface: IntelligentField
      Returns the current value of the field as SaPropertyValue.
      Specified by:
      getPropertyValue in interface IntelligentField
      Returns:
      the field's current value
    • setText

      public void setText(String value) throws org.zkoss.zk.ui.WrongValueException
      Overrides:
      setText in class org.zkoss.zul.impl.InputElement
      Throws:
      org.zkoss.zk.ui.WrongValueException
    • setValueImplicitly

      public void setValueImplicitly(com.saperion.intf.SaPropertyValue val)
      Sets the value of this field and sets the changed-property of this field to true.
      Specified by:
      setValueImplicitly in interface IntelligentField
      Parameters:
      val - value
      See Also:
    • setValueImplicitly

      public void setValueImplicitly(com.saperion.intf.SaPropertyValue value, boolean fireChangedEvent)
      Sets the value of this field and sets the changed-property of this field to true.
      Specified by:
      setValueImplicitly in interface IntelligentField
      Parameters:
      value - value
      fireChangedEvent - if true, a Events.ON_CHANGE event will be fired after the value was set
      See Also:
    • getIntValue

      public Integer getIntValue()
      Returns:
      Integer value, if this is a integer field.
    • getRealValue

      public Double getRealValue()
      Returns:
      Double value, if this is a double field.
    • getIntValues

      public Integer[] getIntValues()
      Returns:
      Integer value, if this is a integer field.
    • getRealValues

      public Double[] getRealValues()
      Returns:
      Double value, if this is a double field.
    • isMultiSelect

      public boolean isMultiSelect()
      Returns:
      True, if field is multiselect.
    • onIndexClear

      public void onIndexClear(org.zkoss.zk.ui.event.Event event)
      Event handler for index clear.
      Specified by:
      onIndexClear in interface IntelligentField
      Parameters:
      event - Event
      See Also:
    • isChanged

      public boolean isChanged()
      Returns true if the value of this field was changed.
      Specified by:
      isChanged in interface IntelligentField
      Returns:
      Value is changed.
      See Also:
    • setEventOnOk

      public void setEventOnOk(ButtonInfo.EventType type)
      Starts event handling on enter key.
      Specified by:
      setEventOnOk in interface IntelligentField
      Parameters:
      type - Event type
      See Also:
    • doChangeValue

      public void doChangeValue(org.zkoss.zk.ui.event.Event event)
      Specified by:
      doChangeValue in interface IntelligentField
      Parameters:
      event - Event
      See Also:
    • getColorError

      public long getColorError()
      Returns:
      Value
      See Also:
      • EditFieldType.getColorError()
    • getColorOk

      public long getColorOk()
      Returns:
      Value
      See Also:
      • EditFieldType.getColorOk()
    • getConditionField

      public int getConditionField()
      Returns:
      Value
      See Also:
      • EditFieldType.getConditionField()
    • getEnableMaximize

      public short getEnableMaximize()
      Returns:
      Value
      See Also:
      • EditFieldType.getEnableMaximize()
    • getFName

      public String getFName()
      Returns:
      Value
      See Also:
      • EditFieldType.getFName()
    • getFont

      public com.saperion.ngc.iform.xml.FontType getFont()
      Returns:
      Value
      See Also:
      • EditFieldType.getFont()
    • getLimit

      public String getLimit()
      Description copied from interface: IntelligentField
      Returns the limit of this field (upper, lower or both).
      Specified by:
      getLimit in interface IntelligentField
      Returns:
      Value
      See Also:
      • EditFieldType.getLimit()
    • getListVersion

      public long getListVersion()
      Returns:
      Value
      See Also:
      • EditFieldType.getListVersion()
    • getMandatory

      public com.saperion.ngc.iform.xml.OverrideKindType getMandatory()
      Returns:
      Value
      See Also:
      • EditFieldType.getMandatory()
    • getPos

      public com.saperion.ngc.iform.xml.PosType getPos()
      Returns:
      Value
      See Also:
      • EditFieldType.getPos()
    • getResFieldCnt

      public int getResFieldCnt()
      Returns:
      Value
      See Also:
      • EditFieldType.getResFieldCnt()
    • getResStyle

      public int getResStyle()
      Returns:
      Value
      See Also:
      • EditFieldType.getResStyle()
    • getVarDataType

      public short getVarDataType()
      Returns:
      Value
      See Also:
      • EditFieldType.getVarDataType()
    • getWxCombo

      public int getWxCombo()
      Returns:
      Value
      See Also:
      • EditFieldType.getWxCombo()
    • getWyCombo

      public int getWyCombo()
      Returns:
      Value
      See Also:
      • EditFieldType.getWyCombo()
    • getXCombo

      public int getXCombo()
      Returns:
      Value
      See Also:
      • EditFieldType.getXCombo()
    • isAllowInactiveLookup

      public boolean isAllowInactiveLookup()
      Returns:
      Value
      See Also:
      • EditFieldType.isAllowInactiveLookup()
    • isAutoComplete

      public boolean isAutoComplete()
      Returns:
      Value
      See Also:
      • EditFieldType.isAutoComplete()
    • isBEnabled

      public boolean isBEnabled()
      Returns:
      Value
      See Also:
      • EditFieldType.isBEnabled()
    • isBPersistent

      public boolean isBPersistent()
      Returns:
      Value
      See Also:
      • EditFieldType.isBPersistent()
    • isHideButtons

      public boolean isHideButtons()
      Returns:
      Value
      See Also:
      • EditFieldType.isHideButtons()
    • isIsVar

      public boolean isIsVar()
      Returns:
      Value
      See Also:
      • EditFieldType.isIsVar()
    • isPersistVar

      public boolean isPersistVar()
      Returns:
      Value
      See Also:
      • EditFieldType.isPersistVar()
    • isRestrictCursor

      public boolean isRestrictCursor()
      Returns:
      Value
      See Also:
      • EditFieldType.isRestrictCursor()
    • isSaveLayout

      public boolean isSaveLayout()
      Returns:
      Value
      See Also:
      • EditFieldType.isSaveLayout()
    • isUseCalendar

      public boolean isUseCalendar()
      Returns:
      Value
      See Also:
      • EditFieldType.isUseCalendar()
    • setAlign

      public void setAlign(com.saperion.ngc.iform.xml.AlignType value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setAlign(com.saperion.ngc.iform.xml.AlignType)
    • setAllowInactiveLookup

      public void setAllowInactiveLookup(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setAllowInactiveLookup(boolean)
    • setAutoComplete

      public void setAutoComplete(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setAutoComplete(boolean)
    • setBEnabled

      public void setBEnabled(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setBEnabled(boolean)
    • setBPersistent

      public void setBPersistent(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setBPersistent(boolean)
    • setColorError

      public void setColorError(long value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setColorError(long)
    • setColorOk

      public void setColorOk(long value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setColorOk(long)
    • setConditionField

      public void setConditionField(int value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setConditionField(int)
    • setEnableMaximize

      public void setEnableMaximize(short value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setEnableMaximize(short)
    • setFName

      public void setFName(String value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setFName(java.lang.String)
    • setFont

      public void setFont(com.saperion.ngc.iform.xml.FontType value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setFont(com.saperion.ngc.iform.xml.FontType)
    • setHideButtons

      public void setHideButtons(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setHideButtons(boolean)
    • setIsVar

      public void setIsVar(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setIsVar(boolean)
    • setLimit

      public void setLimit(String value)
      Description copied from interface: IntelligentField
      Sets the limit type. Possible values are: 'lower', 'upper', 'both'.
      Specified by:
      setLimit in interface IntelligentField
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setLimit(com.saperion.ngc.iform.xml.LimitType)
    • setListVersion

      public void setListVersion(long value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setListVersion(long)
    • setMandatory

      public void setMandatory(com.saperion.ngc.iform.xml.OverrideKindType value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setMandatory(com.saperion.ngc.iform.xml.OverrideKindType)
    • setPersistVar

      public void setPersistVar(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setPersistVar(boolean)
    • setPos

      public void setPos(com.saperion.ngc.iform.xml.PosType value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setPos(com.saperion.ngc.iform.xml.PosType)
    • setResFieldCnt

      public void setResFieldCnt(int value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setResFieldCnt(int)
    • setResStyle

      public void setResStyle(int value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setResStyle(int)
    • setRestrictCursor

      public void setRestrictCursor(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setRestrictCursor(boolean)
    • setSaveLayout

      public void setSaveLayout(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setSaveLayout(boolean)
    • setUseCalendar

      public void setUseCalendar(boolean value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setUseCalendar(boolean)
    • setVarDataType

      public void setVarDataType(short value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setVarDataType(short)
    • setWxCombo

      public void setWxCombo(int value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setWxCombo(int)
    • setWyCombo

      public void setWyCombo(int value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setWyCombo(int)
    • setXCombo

      public void setXCombo(int value)
      Parameters:
      value - Value
      See Also:
      • EditFieldType.setXCombo(int)
    • getElementType

      public IntelligentField.ElementType getElementType()
      Returns the type of this element. The type defines the kind of data and control used for this IntelligentField. See IntelligentField.ElementType for a list of types.
      Specified by:
      getElementType in interface IntelligentField
      Returns:
      Element type
      See Also:
    • getResultBean

      public FieldResultBean getResultBean()
      Returns a bean containing the current value, type, name and limit of this field.
      Specified by:
      getResultBean in interface IntelligentField
      Returns:
      Result bean
      See Also:
    • getEventtarget

      public Set<org.zkoss.zk.ui.Component> getEventtarget(String eventName)
      Reads the event target for the given event name, if set or the root element.
      Specified by:
      getEventtarget in interface EventChild
      Parameters:
      eventName - Event name or null for main target
      Returns:
      Set of event targets
      See Also:
    • setEventtarget

      public void setEventtarget(org.zkoss.zk.ui.Component comp, String eventName)
      Set the event target.
      Specified by:
      setEventtarget in interface EventChild
      Parameters:
      comp - Event target
      eventName - Event name or null for main target
      See Also:
    • postFormButtonEvent

      public void postFormButtonEvent(ButtonInfo info)
      Posts a FormButtonEvent.
      Parameters:
      info - information about the button pressed.
      See Also:
    • postFieldChangeEvent

      public void postFieldChangeEvent(ResultProperty property)
      Posts a FieldChangeEvent.
      Parameters:
      property - the property that was changed
      See Also:
    • getFieldName

      public String getFieldName()
      Returns the name of the field.
      Specified by:
      getFieldName in interface IntelligentField
      Returns:
      Field name
      See Also:
    • isContentValid

      public boolean isContentValid()
      Performs a validation and returns true, if the content is valid.
      Specified by:
      isContentValid in interface IntelligentField
      Returns:
      Field content is valid.
      See Also:
    • isValid

      public boolean isValid()
      Overrides:
      isValid in class org.zkoss.zul.impl.InputElement
      See Also:
      • InputElement.isValid()
    • getEditField

      public com.saperion.ngc.iform.xml.EditFieldType getEditField()
      Returns the EditFieldType defining the properties of this field.
      Specified by:
      getEditField in interface IntelligentField
      Returns:
      the edit field
      See Also:
    • getFormMode

      public FormMode getFormMode()
      Returns:
      An instance of FormMode
    • setDefaultValue

      public void setDefaultValue(String valueAsString)
      Sets the default value.
      Specified by:
      setDefaultValue in interface IntelligentField
      Parameters:
      valueAsString - string representation of value
      See Also:
    • setFieldInactive

      public void setFieldInactive(boolean inactive)
      Sets the fieldInactive parameter. Same as setReadonly(inactive).
      Specified by:
      setFieldInactive in interface IntelligentField
      Parameters:
      inactive - value
      See Also:
    • setReadonly

      public void setReadonly(boolean readonly)
      Sets the readonle state of this field.
      Specified by:
      setReadonly in interface IntelligentField
      Specified by:
      setReadonly in interface org.zkoss.zk.ui.ext.Readonly
      Overrides:
      setReadonly in class org.zkoss.zul.impl.InputElement
      Parameters:
      readonly - readonly
      See Also:
      • InputElement.setReadonly(boolean)
    • isReadonly

      public boolean isReadonly()
      gets the readonly state of this field.
      Specified by:
      isReadonly in interface IntelligentField
      Specified by:
      isReadonly in interface org.zkoss.zk.ui.ext.Readonly
      Overrides:
      isReadonly in class org.zkoss.zul.impl.InputElement
      See Also:
      • InputElement.setReadonly(boolean)
    • isFieldInactive

      public boolean isFieldInactive()
      Returns the fieldInactive parameter.
      Specified by:
      isFieldInactive in interface IntelligentField
      Returns:
      fieldInactive
      See Also:
    • setDisabled

      public void setDisabled(boolean disabled)
      Sets the disabled state of this field.
      Specified by:
      setDisabled in interface org.zkoss.zk.ui.ext.Disable
      Specified by:
      setDisabled in interface IntelligentField
      Overrides:
      setDisabled in class org.zkoss.zul.impl.InputElement
      Parameters:
      disabled - Disabled
      See Also:
      • InputElement.setDisabled(boolean)
    • setFieldName

      public void setFieldName(String name)
      Sets the name of the field. The name is required to be the same as in the database table representing the DDC used.
      Specified by:
      setFieldName in interface IntelligentField
      Parameters:
      name - field name
      See Also:
    • validate

      public void validate()
      Starts validation of the field.
      Specified by:
      validate in interface IntelligentField
      See Also:
    • getParentForm

      public IntelligentFormView getParentForm()
      Returns the parent form or null if this field is not part of a form.
      Specified by:
      getParentForm in interface IntelligentField
      Returns:
      parent form or null
      See Also:
    • setChangedImplicitly

      public void setChangedImplicitly()
      Sets the changed-property of this field to true.
      Specified by:
      setChangedImplicitly in interface IntelligentField
      See Also:
    • setChangedImplicitly

      public void setChangedImplicitly(boolean fireChangedEvent)
      Sets the changed-property of this field to true.
      Specified by:
      setChangedImplicitly in interface IntelligentField
      Parameters:
      fireChangedEvent - if true, a Events.ON_CHANGE event will be fired
      See Also:
    • updateAttribute

      public void updateAttribute(String attr, Object value)
      Performs a smartUpdate on the specified attribute.
      Specified by:
      updateAttribute in interface IntelligentField
      Parameters:
      attr - attribute name
      value - attribute value
      See Also:
    • isNoLocalize

      public boolean isNoLocalize()
      Returns the noLocalize parameter.
      Specified by:
      isNoLocalize in interface Localized
      Returns:
      noLocalize
      See Also:
    • setNoLocalize

      public void setNoLocalize(boolean value)
      Sets the noLocalize parameter that can be used to disable localization of this component.
      Specified by:
      setNoLocalize in interface Localized
      Parameters:
      value - value
      See Also:
    • setMultiSearchItems

      public void setMultiSearchItems(String[] values)
      Sets the values to display for multi-selection. See LookupTextField on how to enable multiselection mode.
      When the field is in multiselection mode, the values defined in the form can be replaced by using this method. The field will not show values retrieved from the lookup-table when it is in multiselection mode. This method throws an UnsupportedOperationException when the field is not in multiselection mode.
      Parameters:
      values - Values to show in multiselect-popup
    • generateUUID

      public String generateUUID()
      Specified by:
      generateUUID in interface Identifiable
      Returns:
      the generated uuid for the DOM tree
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class org.zkoss.zk.ui.AbstractComponent
      See Also:
      • AbstractComponent.toString()
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface IntelligentField
      Returns:
      true if the field's value is empty.
      See Also:
    • addCondition

      public void addCondition(String fieldName, Object value, com.saperion.constants.SaConstants.SaFieldType fieldType)
      Adds a condition to the field that will be used to search for items displayed in the field's result list.
      Parameters:
      fieldName - the name of the field to check
      value - the value to check for
      fieldType - the type of the field (an SaConstants.SaFieldType)
    • addCondition

      public void addCondition(String fieldName, Object value, com.saperion.constants.SaConstants.SaFieldType fieldType, boolean multiValue)
      Adds a condition to the field that will be used to search for items displayed in the field's result list.
      Parameters:
      fieldName - the name of the field to check
      value - the value to check for
      fieldType - the type of the field (an SaConstants.SaFieldType)
      multiValue - whether the field used in the condition is a multivalue-field or not
    • removeCondition

      public void removeCondition(String fieldName)
      Removes a condition from the field.
      Parameters:
      fieldName - name of the field to remove the condition for
    • getSelectedRow

      public ResultProperties getSelectedRow()
      Description copied from interface: LookupField
      Returns the selected row in the lookup table belonging to this lookup field.
      Specified by:
      getSelectedRow in interface LookupField
      Returns:
      ResultProperties containing the selected row or null, if no row was selected so far
    • clearSelectedRow

      public void clearSelectedRow()
      Description copied from interface: LookupField
      Clears the selected row from the field. The lookup table will not be changed.
      Specified by:
      clearSelectedRow in interface LookupField
    • clear

      public void clear()
      Description copied from interface: IntelligentField
      Clears the value(s) of this field.
      Specified by:
      clear in interface IntelligentField