...
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 a choose dialog is configured in the app to browse the contents.
...
Simple link field definition
...
:
Code Block |
---|
|
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 |
---|
|
|
Advanced Tables - Table Plus |
---|
heading | 0 |
---|
enableHeadingAttributes | false |
---|
enableSorting | false |
---|
class | m5-configuration-tree |
---|
enableHighlighting | false |
---|
|
Node name | Value |
mgnl-nform | | | | identifierToPathConverter | | info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator |
| | info.magnolia.dam.app.ui.field.DamFilePreviewComponent |
| contacts |
| link |
| dam |
| Select image |
| Image |
Include Page |
---|
| _referencing Referencing fields shortcut info - 5 UI |
---|
| _referencing Referencing fields shortcut info - 5 UI |
---|
|
Field-specific properties:
...
Include Page |
---|
| _Common field properties - 5 UI |
---|
| _Common field properties - 5 UI |
---|
|
Anchor |
---|
| link-to-non-jcr |
---|
| link-to-non-jcr |
---|
|
Using link fields with JCR-agnostic target apps
...
- It extends a custom Vaadin field,
- It stores a value which must be String.
- It has a callback (
Javadoc resource link |
---|
rangeHigherVersion | 6.0 |
---|
className | info.magnolia.ui.api.app.ChooseDialogCallback |
---|
renderType | asynchronous |
---|
|
). - 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 |
---|
rangeHigherVersion | 6.0 |
---|
className | info.magnolia.ui.vaadin.integration.jcr.JcrItemId |
---|
renderType | asynchronous |
---|
|
. 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.
...