Skip to content

Attribute Value Options

olaf-boede edited this page Aug 7, 2013 · 12 revisions

External interface

Attributes with selectable values provide their options using the method: PmAttr#getOptionSet().

If the user selects an option, the value of the selected option (PmOption.html#getValue()) will be used to update the attribute.

Some view binding components (pm4j:selectOneMenu, PbJComboBox, PbComboBox ...) use this interface to render and handle the provided options.

Implementation interface

pm4j offers the following implementation interfaces for option definition:

  • Define it in Java by overriding PmAttrBase.html#getOptionSetImpl().
    This way you have to write some lines of code but it provides that advantage that you can control all details.

See: PmAttrOptionsProvidedByGetOptionsImplTest

  • Override PmAttrBase.html#getOptionValues() and define the details for option titles, ids etc. using the annotation @PmOptionCfg.
    This implementation interface provides often a fair balance with some expressions that help to control the option generation and some traceable Java code that provides the objects to represent as options.
    See: PmAttrOptionsProvidedByGetOptionValuesMethodTest
  • Define it by using the attribute annotation @PmOptionCfg.
    The annotation based implementation allows to define the option feature defintion within a single line of code. On the other hand it may add some weak - only expression based - references to java methods without compile time checks.
    See: PmAttrOptionsProvidedByCfgTest

The attribute class PmAttrEnumImpl has a default implementation that provides all enum-values as options. You may change this default implementation by overriding PmAttrBase.html#getOptionSetImpl().
See: PmAttrOptionsForEnumsTest

Clone this wiki locally