Class FWAbstractFormSubComponent

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
net.simplace.pipe.formcomponents.FWAbstractFormSubComponent
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
FWCheckboxChoiceSubComponent, FWDaySubComponent, FWLabelChoiceSubComponent, FWMonthSubComponent, FWSingleCheckboxChoiceSubComponent, FWYearSubComponent

public abstract class FWAbstractFormSubComponent extends JPanel
Abstract class that is supposed to be overwritten by subcomponent implementations. Subcomponents may be used to assemble compound form components (see FWDateFormComponent) or to create form components that have a different appearance, depending on input parameters (see FWChoiceFormComponent). Subcomponents cannot be directly used in forms but can only be contained in a form component that inherits from FWAbstractFormComponent. Form components may register change listeners on subcomponents to get notified of changes. This may be useful to keep several subcomponents synchronized and to keep the form component's value up-to-date. However, it is up to the implementation of the subcomponent to notify listeners by calling fireStateChanged() whenever its value changes!
Author:
Christoph Kunze
See Also:
  • Field Details

    • iObservable

      protected net.simplace.core.FWObservable iObservable
      parameters of the functionality
    • iIsEnabled

      protected boolean iIsEnabled
      enabled state (the Swing enabled state is not used)
    • iFormComponentParameterMap

      protected Map<String,Object> iFormComponentParameterMap
      parameters of the containing form component
  • Constructor Details

    • FWAbstractFormSubComponent

      public FWAbstractFormSubComponent(boolean aIsEnabled, net.simplace.core.FWObservable aObservable, Map<String,Object> aFormComponentParameterMap)
      Parameters:
      aIsEnabled - true if the subcomponent is enabled
      aObservable - parameters of the functionality
      aFormComponentParameterMap - parameters of the containing form component
  • Method Details

    • getValue

      public abstract String getValue()
      Returns:
      value of the implemented subcomponent
    • getSelectedValueList

      public abstract List<Object> getSelectedValueList()
      Returns:
      the selected values (for choice subcomponents with multiple selection)
    • isEnabled

      public boolean isEnabled()
      Overrides:
      isEnabled in class Component
    • setEnabled

      public void setEnabled(boolean aEnabled)
      Overrides:
      setEnabled in class JComponent
    • setValue

      public abstract void setValue(String aValue)
      Allows to set the value of the implemented subcomponent
      Parameters:
      aValue - String representation of the value to be set
    • addChangeListener

      public void addChangeListener(ChangeListener aListener)
      Allows form components to register change listeners on subcomponents in order to get notified of changes. Implementations of subcomponents MUST call fireStateChanged() whenever their value changes, so that change listeners get notified.
      Parameters:
      aListener - Change Listener to be registered
    • removeChangeListener

      public void removeChangeListener(ChangeListener aListener)
      Allows form components to unregister previously registered change listeners on subcomponents
      Parameters:
      aListener - The previpusly registered change listener
    • fireStateChanged

      protected void fireStateChanged()
      Notifies change listeners of changes to the subcomponent. This method MUST get called, whenever the value of the subcomponent changes. However, calling it is up to the specific implementation of this abstract class.
    • getChangeListeners

      public ChangeListener[] getChangeListeners()
      Returns:
      An array of all the change listeners that are currently registered on this component
    • getLocaleValue

      protected String getLocaleValue(String aKey)
      Reads a localised text <locale prefix>.FormComponent.<key> from LocaleBundle.
      Parameters:
      aKey - key of the text
      Returns:
      the localised text
    • createSqlOrCondition

      protected String createSqlOrCondition(String aColumn, List<?> aValues)
      Creates the SQL condition of the parameter sql_where_param for the selected values: column='value1' OR column='value2' (format as before). Security: the values are escaped as SQL string literals (a quote is doubled), and the column name must be a plain SQL identifier; before, both were concatenated unchecked into the SQL (SQL injection via option values).
      Parameters:
      aColumn - the column name (parameter sql_where_param)
      aValues - the selected values; null values are compared as empty string
      Returns:
      the condition, or an empty string if the column name is no valid identifier (error is logged)