Skip to content

Advanced customization

amischler edited this page Mar 21, 2013 · 5 revisions

Advanced customization

Foreword

You are at the right place if you want to :

  • customize the components used to edit your fields
  • tweak the binding between the model and the view
  • support type of fields that are not supported by default in FXForm2

Customizing the nodes used in FXForm2

The FactoryProvider

Almost all nodes used in FXForm2 are created using FactoryProvider. A FactoryProvider is responsible for providing factories for all elements in your form.

FXForm2 uses 4 different factory providers for each kind of node (label, editor, tooltip, constraint messages). These providers have default values that should match almost all of your needs. However, you can use any FactoryProvider you want for each kind if you need, using the appropriate setters in https://github.com/dooApp/FXForm2/blob/master/core/src/main/java/com/dooapp/fxform/FXForm.java.

Kind Default factory provider Description
Labels DefaultLabelFactoryProvider A provider providing a LabelFactory
Editor DefaultFactoryProvider A customizable default provider
Tooltip DefaultTooltipFactoryProvider A provider providing a AutoHidableLabelFactory
Constraint messages DefaultConstraintFactory A provider providing a factory creating ConstraintLabel

Customizing the DefaultFactoryProvider

The DefaultFactoryProvider can be customized to add support for new type of elements or to customize the factories used for the default types.

You have two way to configure the DefaultFactoryProvider

The static way

DefaultFactoryProvider.addGlobalFactory(myHandler, myFactory)
  • myHandler is the ElementHandler performing the matching between a given element and myFactory
  • myFactory is your factory that should be used when the handler matches This static configuration can be used to configure all forms created after that.

The local way

DefaultFactoryProvider provider = new DefaultFactoryProvider();
provider.addFactory(myHandler, myFactory);

Clone this wiki locally