Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • It allows to bind form views to complex nested datastructures and fine tune such binding. E.g. if a form binds a contact address as a separate sub-form (in M5 words - e.g. as a composite field), the Magnolia user might want to use a contact's child node to store the data (item provider that resolves a sub-node can be used), or store the properties directly on the contact node keeping it flat (self-reference item provider case).
  • item providers get reference items as context. I.e. an address editor from the example upon data binding will get the root contact node so that it would be trivial to resolve the corresponding sub-node if needed. Forms are always populated and persisted from top of the hierarchy to the bottom.
  • Item providers kick in the form lifecycle only twice (typically): when the data is fetched from the backend (to populate the form) and when the updated data needs to be flushed from the Vaadin components back to the backend (on form commit).
  • item providers yield items wrapped into Optional container, so it is fine not to return anything from the item provider implementation (in such case though, the form data may not be populated or saved back to the backend).

Where are they used

Item providers are used in the following two use cases:

  • 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.

Advantages of item providers

...

  • Now, 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 6 UI, data updates should be piped into the 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 are they used

Item providers are used in the following two use cases:

  • 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

The following item provider types are currently available:

...