Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
HTML Wrap
floatright
classmenu

Related topics:

...

  • An item provider only needs to know how to access the data. In contrast, the transformers in the 5 UI framework were responsible for both types of data operations – reading and writing. In Magnolia 6 UI, data updates should be piped into back-end items via simple fields by means of Vaadin 8 data binding (Binder objects).
  • Unlike transformers, item providers do not have to deal with the deprecated Vaadin 7 Item API and do not require manual verifications that child properties are populated within an item.
  • Item providers have a clearer concept of chaining. They get a reference of an item from a previous level in the hierarchy, making the whole complex data binding process recursive.
  • The number of provider types is much lower in Magnolia 6 UI, compared to a relatively high number of field transformers in the 5 UI.
  • There's also provider implementations that can handle JSON structures, task and notifications items, assets or specific product content items.

Where

...

they can be used

Item providers can be used in:

  • Item provider definition in a detail subapp
  • Item provider definition In a form containing composite and complex fields. In this use, the provider replaces the former field transformer functionality that is part of the UI framework 5, but no longer part of the Magnolia 6 UI.

Provider types

For

...

any data

...

source

$type (class shortcut name)class Class name and description
jcrChildNodeProvidercurrentItemProvider

info.magnolia.ui.editor.

JcrChildNodeProviderDefinition

Resolves child JCR node from the parent.

CurrentItemProviderDefinition

Returns the parent node. Suitable for sub-forms only since it relies on a parent.

Warning

Do not use currentItemProvider with multi fields. The same nodes could be resolved by multiple fields that use currentItemProvider, which means their content would be overwritten. Additionally, if a multi field is not configured to resolve nodes strictly (the strict property is set to false by default), it will resolve irrelevant nodes from the parent and likely result in errors.

Note

If you use currentItemProvider with composite or switchable fields, make sure that none of the inner field names clash with:

  • Other inner field names at the level where currentItemProvider is used
  • Other field names one level up where the composite or switchable field is defined

That is, every field at every level must have a unique name. Otherwise, nodes sharing the same name could be resolved by multiple fields that use currentItemProvider, which means their content would be overwritten.

Code Block
languageyml
titleExample name conflict
collapsetrue
form:
  properties:
    first_compositeField:
      $type: compositeField
      itemProvider:
        $type: currentItemProvider
      properties:
        inner_simple: # duplicate name
          $type: textField # first text
        inner_simple2:
          $type: textField # second text
    second_compositeField:
      $type: compositeField
      itemProvider:
        $type: currentItemProvider
      properties:
        inner_simple3:
          $type: textField # third text
        inner_simple: # duplicate name
          $type: textField # fourth text

# Problem with using currentItemProvider
edited_node:
  inner_simple: fourth text # first text is overwritten by second inner_simple
  inner_simple2: second text
  inner_simple3: third text

# Using jcrChildNodeProvider with both composite fields would fix the problem
edited_node:
  first_compositeField:
    inner_simple: first text
    inner_simple2: second text
  second_compositeField:
    inner_simple3: third text
    inner_simple: fourth text # no name conflict

For JCR data source

$typeclass and description
jcrChildNodeProvider
jcrCurrentNodeProvider

info.magnolia.ui.databinding.JcrCurrentNodeProviderDefinition

Returns the parent node.

jcrNodeFromLocationProvider

info.magnolia.ui.editor.

JcrNodeFromLocationResolutionDefinition

JcrChildNodeProviderDefinition

Resolves a JCR child node

content

from the

current location.

...

parent. Suitable for sub-forms only since

...

it relies on a parent

...

.

For JSON data sources

restuiJsonChildNodeProviderDefinition a JSON JsonFieldPropertyProvider.restfieldJsonFieldPropertyProviderDefinition JSON data source. Typically, such a strategy would be ,
Info

jcrChildNodeProvider is used by default in 

Javadoc resource link
className

$type (class shortcut name)Class name and description
jsonProvider

info.magnolia.

rest

ui.

ui.JsonItemProviderStrategyDefinition

Replaces the {id} path parameter with the one passed in the location and then fetches the result using a configured REST call.

jsonChildNodeProvider

field.JcrMultiFieldDefinition
renderTypeasynchronous
.

jcrGetIndexedChildNode

info.magnolia.

ui.

editor.

JcrIndexedChildNodeProvider

Resolves

an indexed JCR child

node from the parent. Suitable for sub-forms only since it relies on a parent.

jcrGetProperty

info.magnolia

.ui.

editor.

JcrPropertyProvider

Proposes a

JCR node property as an item

datasource. Typically used in complex fields with sub-editors

where a single field entry needs to be exposed as an editor.

Info

jcrGetProperty is used by default in 

Javadoc resource link
classNameinfo.magnolia.ui.field.JcrMultiValueFieldDefinition
renderTypeasynchronous
.

jcrNodeFromLocationProvider

info.magnolia.ui.editor.JcrNodeFromLocationResolutionDefinition

Resolves JCR node content from the current location.

For JSON data source

jsonMultiFieldProviderJsonMultiFieldProviderDefinitionResolves child from the parent in a multi field context. Suitable for sub-forms only since it relies on a parent, such a strategy would be ,
$typeclass and description
jsonFieldPropertyProvider

info.magnolia.rest.ui.field.

JsonFieldPropertyProviderDefinition

Proposes a

JSON node

property as an item data source. Typically used in complex fields with sub-editors where a single field entry needs to be exposed as an editor.

jsonMultiFieldPropertyProvider

info.magnolia.rest.ui.field.JsonMultiFieldPropertyProviderDefinition

Proposes a JSON node property as an item data source in a multi field context. Typically

used in complex fields with sub-editors

where a single field entry needs to be exposed as an editor.

jsonMultiFieldProvider

info.magnolia.rest.ui.field.JsonMultiFieldProviderDefinition

Resolves a JSON child node from the parent in a multi field context. Suitable for sub-forms only since it relies on a parent.

jsonProvider

info.magnolia.rest.ui.JsonItemProviderStrategyDefinition

...

Replaces the {id} path parameter with the one passed in the location and then fetches the result using a configured REST call.

In subapp definition

The jcrNodeFromLocationProvider is used for example in the Pages app (see line 7 below). This provider resolves a JCR node from its location context:

...

Code Block
languageyml
linenumberstrue
  view:
    label: View Commit
    class: info.magnolia.ui.contentapp.detail.DetailDescriptor
    datasource:
      $type: jsonDatasource
      restClient: bitbucket
      restCall: commit
      jsonPathExpressions:
        properties:
          author: '$.author.raw'
    actions:
      cancel:
        label: Cancel
        $type: closeAction
    itemProvider:
      $type: jsonProvider

In

...

form definition

A provider strategy can be applied to handle data-read operations in forms with complex field. For example, see the jcrChildNodeProvider in the following definition of a complex field called address , composed of two simple fields, city and country .

Image RemovedImage Added

Code Block
languageyml
linenumberstrue
        address:
          label: address
          i18n: true
          $type: compositeField
          itemProvider:
            $type: jcrChildNodeProvider
          properties:
            city:
              label: city
              $type: textField
            country:
              label: country
              i18n: true
              $type: textField

...