You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

Introduction

Magnolia 5.1 introduce a new way to handle properties bound to a dialog field. Until Magnolia 5.1 the only way to modify the default behavior (a field is bound to a simple property) was to override the FieldBuilder.getOrCreateProperty(..  method.
Now by configuration we have the possibility to define custom way to initialize a property and link it to a field. This is us full for complex fields like MultiField CompositeField that needs more than one property bound to them.

Basic Concept

A Field  is linked to a Property  used to store the field value. This Property is set by the FieldBuilder based on the passed Item .
For example a TextField named 'text' has a Property bound to the Item  Property 'text'.

Mockup image file mockup_item.png (version -1) not found. Did someone delete it?

Now for a MultiField, the related Property can no more be a simple Property but rather a ListProperty . This ListProperty will be populated with the individual field Property values.
This is the first information needed in order to handle complex fields: The PropertType (Basic, List, Composite,...)

Mockup image file mockup_fields 2.png (version -1) not found. Did someone delete it?

The way values of the ListProperty is set and retrieve from the related Item is also something we would like to configure. For example I may want to have a MultiField composed of DateField stored in a single multi value.
The same field may be used in another place but the values have to be stored as sub item (nodes) elements.
PropertyHandler is the second information needed. PropertyHandler handle the way property element are retrieve and set to an Item.

Configuration

These configurations are done in the common fields Properties.

PropertyDescriptionDefault valueValid values
propertyBuilder

Concrete property Type and Handler definition. Optional.
If not defined,  BasicProperty and BasicPropertyHandler are used.
(warning) ComplexeFieldDefinition may define default property Type and Handler in their constructor.

  
    propertyHandlerImplementation class of  PropertyHandler set to the propertyType used to set and get values in certain format.  
    propertyTypeImplementation class of CustomPropertyType set as Field PropertyDatasource.  

Default behavior

Basic Property

By default BasicProperty and BasicPropertyHandler are used.

The field is created based on the related form ItemBasicPropertyHandler will:

  • Retrieve the Item.property if this property already exist on the Item.
    property is search based on the Field name defined as name property on the field definition. 
  • Create the Item.property if this property do not yet exist on the Item.
    property is created based on the following field definition:
    • type: property will get the desired type
    • defaultValue: if define, the string representation of the default field value is converted to a new typed value.

Composite Property

Composite Property (CompositeProperty) are used by the following fields:

  • CompositeField
  • SwitchableField

CompositeField

This field is by default bound with  SimplePropertyCompositeHandler . This handler will store each single field part of the CompositeField as single suffixed property.
Assume that your CompositeField is called 'composite' and contains two fields: a text field called 'simpleText' and a date field called 'simpleDate'. The  values will be stored as following:

Node nameValue

compositesimpleText
some text value

compositesimpleDate
2006-05-01T21:47:58.230+02:00

 

SwitchableField

This field is by default bound with  SwitchableSimplePropertyCompositeHandler . This handler will store each single field part of the SwitchableField as single suffixed property.
Assume that your SwitchableField is called 'switchable' and contains two fields: a text field called 'simpleText' and a date field called 'simpleDate'. The  values will be stored as following:

Node nameValue

switchable
text (last tab selected)

switchablesimpleText
some text value

switchablesimpleDate
2006-05-01T21:47:58.230+02:00

List Property

List Property (ListProperty) are used by the following field:

  • MultiField

MultiField

This field is by default bound with  MultiValuesPropertyMultiHandler . This handler will store each single field part of the MultiField as a multiValue property (Basically a JCR multiValue property represented a a Typed List property).

i18n

All default implementation support the i18n definition.
If for example you have two language defined ('en', 'de') with 'en' set as default language:

Node nameValue

formNode

 

   

simpleText
Simple English Text
   

simpleText_de
Einfache deutsche Text
   

multiValueText
English1,English2,English3
   

multiValueText_de
Deutsche1,Deutsche2

If you want to implement your own implementation of PropertyHandler that support i18n, your implementation will need to:

  • return true for PropertyHandler.hasI18NSupport() 
  • implement a compatible Magnolia i18n logic.

Implemented

Implemented Property

Hierarchy

Mockup image file mockup_dd.png (version -1) not found. Did someone delete it?

 

BaseProperty

BaseProperty implements the following basic mechanism:

  • Handle i18n support.
  • Delegate the configured handler the request  when property.getValue() and property.setValue() are called.

Implemented Handlers

 

Limitation

 

How to

  • No labels