Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: MOTION-157

...

The central property when defining a link field is appName - the name of the Magnolia app to choose the item from. The target app is responsible for providing a view that is suitable for selecting the item. When the target app is a content app, the workbench in the browser subapp is a suitable view and it is used by default. For more complex apps like the Assets app - 5 UI, a choose dialog is configured in the app to browse the contents.

...

Simple link field definition:

JCR node
Localtab Group
Localtab
activetrue
titleYAML file
Code Block
languagejs
form:
 tabs:
    - name: tabImage
      label: Image 
      fields:
        - name: image
          fieldType: link
          targetWorkspace: dam
          appName: assets
          label: Select image
          identifierToPathConverter:
            class: info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator
          contentPreviewDefinition:
            contentPreviewClass: info.magnolia.dam.app.ui.field.DamFilePreviewComponent
Localtab
title
Advanced Tables - Table Plus
heading0
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse
Node nameValue

Mgnl n
form

Mgnl n
tabs

Mgnl n
tabImage

Mgnl n
fields

Mgnl n
image

Mgnl n
identifierToPathConverter

Mgnl p
class

info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator

Mgnl n
contentPreviewDefinition

Mgnl p
contentPreviewClass

info.magnolia.dam.app.ui.field.DamFilePreviewComponent

Mgnl p
appName

contacts

Mgnl p
fieldType

link

Mgnl p
targetWorkspace

dam

Mgnl p
label

Select image

Mgnl p
label

Image

Include Page
_Referencing fields shortcut info - 5 UI
_Referencing fields shortcut info - 5 UI
Include Page
_referencing fields shortcut info_referencing fields shortcut info

Field-specific properties:

...

Include Page
_Common field properties - 5 UI
_Common field properties - 5 UI

...

  • It extends a custom Vaadin field,
  • It stores a value which must be String.
  • It has a callback ( 
    Javadoc resource link
    rangeHigherVersion6.0
    classNameinfo.magnolia.ui.api.app.ChooseDialogCallback
    renderTypeasynchronous
    ). 
  • When choosing an item, the method #onItemChosen(actionName, chosenValue) is triggered on the callback. The parameter choosenValue is of type Object and is the corresponding ItemId of the item of the content app . (See see ItemIds and Items). 

Depending on the implementation of the content app, the ItemId may be a String or a more complex Object. A well-known ItemId is 

Javadoc resource link
rangeHigherVersion6.0
classNameinfo.magnolia.ui.vaadin.integration.jcr.JcrItemId
renderTypeasynchronous
. The callback properly handles JcrItemId, and if it is another type, String.valueOf(chosenValue) is saved to the link field.

...

field

...

.

...

When using LinkField with JCR-agnostic target apps that use complex ItemIds that extend  Object , override the public String toString() method on the implementation of the itemId.

...