Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: updated javadoc macros

...

Info
titleBest practice


Excerpt

The delegating transformers classes should be your first choice since they are the most versatile. If you can, use DelegatingCompositeFieldTransformer or DelegatingMultiValueFieldTransformer rather than the other available classes.


BasicTransformer

Javadoc
className0info.magnolia.ui.form.field.transformer.basic.BasicTransformer
 stores
renderTypeasynchronous
stores the field value in a single property. The property has the same name as the field definition node. You can provide a different name with a name property in the field definition. This transformer creates a new property if the property does not yet exist.

...

CompositeTransformer

Javadoc
className0info.magnolia.ui.form.field.transformer.composite.CompositeTransformer
renderTypeasynchronous
stores each child field value as a single property. Composite fields which consist of multiple child fields use CompositeTransformer by default.

...

DelegatingCompositeFieldTransformer

Javadoc
className0info.magnolia.ui.form.field.transformer.composite.DelegatingCompositeFieldTransformer
renderTypeasynchronous
stores each child field value as a single property. The difference between this transformer and the other composite transformers is that it uses the child field name as the storage property  name.

Transformer class:  info.magnolia.ui.form.field.transformer.composite.DelegatingCompositeFieldTransformer DelegatingCompositeFieldTransformer

Example composite field definition containing a text field and date field that uses DelegatingCompositeFieldTransformer :

Localtab Group


Localtab
activetrue
titleYAML file


Code Block
languagejs
form:
  tabs:
    - name: tabEvent
      label: Event
      fields:
        - name: composite
          class: info.magnolia.ui.form.field.definition.CompositeFieldDefinition
          transformerClass:  info.magnolia.ui.form.field.transformer.composite.DelegatingCompositeFieldTransformer
          label: Event
          fields:
            - name: title
              class: info.magnolia.ui.form.field.definition.TextFieldDefinition
              label: Title
            - name: date
              class: info.magnolia.ui.form.field.definition.DateFieldDefinition
              label: Date



Localtab
titleJCR node


Advanced Tables - Table Plus
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse


Node nameValue

Mgnl n
form


Mgnl n
tabs


Mgnl n
tabEvent


Mgnl n
fields


Mgnl n
composite


Mgnl n
fields


Mgnl n
title


Mgnl p
class

info.magnolia.ui.form.field.definition.TextFieldDefinition

Mgnl p
label

Title

Mgnl n
date


Mgnl p
class

info.magnolia.ui.form.field.definition.DateFieldDefinition

Mgnl p
label

Date

Mgnl p
class

info.magnolia.ui.form.field.definition.CompositeFieldDefinition

Mgnl p
label

Event

Mgnl p
transformerClass

info.magnolia.ui.form.field.transformer.composite.DelegatingCompositeFieldTransformer




...

NoOpCompositeTransformer

Use

Javadoc
className0info.magnolia.ui.form.field.transformer.composite.NoOpCompositeTransformer
renderTypeasynchronous
 for for composite field that is inside a multivalue parent parent field. "NoOp" means no operation – NoOpCompositeTransformer  does not perform any  writeToItem  or  readFromItem  operations, it just acts as a property container. The transformer of the parent multivalue field does the reading and writing of the item structure to the repository. You can use any of the multivalue transformers below in the parent. The parent transformer passes the properties to the  NoOpCompositeTransformer  as a Vaadin  PropertysetItem .

Transformer class: info.magnolia.ui.form.field.transformer.composite.NoOpCompositeTransformer

...

Switchable fields use

Javadoc
className0info.magnolia.ui.form.field.transformer.composite.SwitchableTransformer
 by
renderTypeasynchronous
by default. This transformer stores the selected field value as a single suffixed property.

...

MultiValueTransformer

Javadoc
className0info.magnolia.ui.form.field.transformer.multi.MultiValueTransformer
renderTypeasynchronous
 is is the default transformer for  multivalue  fields. The transformer stores field values in a LinkedList<T> collection. The linked list is then automatically converted to a JCR multivalue property when persisted to the JCR.  In the repository it looks like a typical array: comma-separated and enclosed in square brackets.

...

MultiValueJSONTransformer

Javadoc
className0info.magnolia.ui.form.field.transformer.multi.MultiValueJSONTransformer
renderTypeasynchronous
stores the values as a comma-separated list of Strings.

...

DelegatingMultiValueTransformer

Javadoc
className0info.magnolia.ui.form.field.transformer.multi.DelegatingMultiValueFieldTransformer
renderTypeasynchronous
 delegates delegates the responsibility of storing field values to the parent field. In doing so, this transformer creates a list of Item objects. The child field uses the Item to create and retrieve its own properties. Delegation makes it possible to nest unlimited levels of fields. For example, create a composite field which contains a multivalue field which contains a switchable field and so on.

...

(warning) Use the more versatile DelegatingMultiValueTransformer instead of this transformer if you can.

Javadoc
className0info.magnolia.ui.form.field.transformer.multi.MultiValueChildrenNodeTransformer
renderTypeasynchronous

MultiValueChildrenNodeTransformer doesn't create a node for the multivalue parent field at all. It creates nodes for the child fields and stores their values as properties. This structure is equivalent to the JCR structure of the form Item.

...

(warning) Use the more versatile DelegatingMultiValueTransformer instead of this transformer if you can.

Javadoc
className0info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodeTransformer
renderTypeasynchronous
 first first creates a node for the parent multivalue field. It then stores the child fields as numbered properties.

...

(warning) Use the more versatile DelegatingMultiValueTransformer instead of this transformer if you can.

Javadoc
className0info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodeTransformer
renderTypeasynchronous
 first first creates a node for the parent multivalue field. It then stores the child fields as subnodes and their values as properties.

...

(warning) Use the more versatile DelegatingMultiValueTransformer instead of this transformer if you can.

Javadoc
className0info.magnolia.ui.form.field.transformer.multi.MultiValueSubChildrenNodePropertiesTransformer
renderTypeasynchronous
is equivalent to MultiValueChildrenNodeTransformer but it is able to handle a composite field as the child of the multivalue parent.

...