info.magnolia.ui.form.field.factory
Class SelectFieldFactory<D extends SelectFieldDefinition>

java.lang.Object
  extended by info.magnolia.ui.form.AbstractFormItem
      extended by info.magnolia.ui.form.field.factory.AbstractFieldFactory<D,Object>
          extended by info.magnolia.ui.form.field.factory.SelectFieldFactory<D>
Type Parameters:
D - type of definition
All Implemented Interfaces:
FieldFactory, FormItem
Direct Known Subclasses:
OptionGroupFieldFactory, TwinColSelectFieldFactory

public class SelectFieldFactory<D extends SelectFieldDefinition>
extends AbstractFieldFactory<D,Object>

Creates and initializes a selection field based on a field definition.


Field Summary
protected  com.vaadin.ui.AbstractSelect select
           
 
Fields inherited from class info.magnolia.ui.form.field.factory.AbstractFieldFactory
definition, field, item
 
Constructor Summary
SelectFieldFactory(D definition, com.vaadin.data.Item relatedFieldItem)
           
 
Method Summary
protected  Object createDefaultValue(com.vaadin.data.Property<?> dataSource)
          Set the value selected.
protected  com.vaadin.ui.AbstractSelect createFieldComponent()
          Implemented by subclasses to create and initialize the Vaadin Field instance to use.
protected  org.apache.jackrabbit.commons.predicate.Predicate createRemoteOptionFilterPredicate()
           
protected  com.vaadin.ui.AbstractSelect createSelectionField()
          Used to initialize the desired subclass of AbstractSelect field component.
protected  Class<?> getDefinitionType()
           
 com.vaadin.server.Resource getIconResource(SelectFieldOptionDefinition option)
          Default Implementation to retrieve an Icon.
protected  String getRemoteOptionsName(javax.jcr.Node option, String propertyName)
          Get the specific node property.
protected  String getRemoteOptionsValue(javax.jcr.Node option, String propertyName)
          Get the specific node property.
 List<SelectFieldOptionDefinition> getSelectFieldOptionDefinition()
          Get the list of SelectFieldOptionDefinition.
 void setPropertyDataSourceAndDefaultValue(com.vaadin.data.Property<?> property)
          Make sure to set defaultValue whenever value is null and nullSelectionAllowed is false, i.e.
 
Methods inherited from class info.magnolia.ui.form.field.factory.AbstractFieldFactory
createField, getDefaultFieldType, getFieldDefinition, getFieldType, getI18nBasename, getView, initializeConverter, initializeTransformer, setComponentProvider, setFieldValidatorFactoryFactory, setI18nContentSupport, setPropertyDataSourceDefaultValue
 
Methods inherited from class info.magnolia.ui.form.AbstractFormItem
getMessage, getMessages, getParent, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface info.magnolia.ui.form.FormItem
getMessages, getParent, setParent
 

Field Detail

select

protected com.vaadin.ui.AbstractSelect select
Constructor Detail

SelectFieldFactory

public SelectFieldFactory(D definition,
                          com.vaadin.data.Item relatedFieldItem)
Method Detail

createFieldComponent

protected com.vaadin.ui.AbstractSelect createFieldComponent()
Description copied from class: AbstractFieldFactory
Implemented by subclasses to create and initialize the Vaadin Field instance to use.

Specified by:
createFieldComponent in class AbstractFieldFactory<D extends SelectFieldDefinition,Object>

createSelectionField

protected com.vaadin.ui.AbstractSelect createSelectionField()
Used to initialize the desired subclass of AbstractSelect field component. Subclasses can override this method.


getSelectFieldOptionDefinition

public List<SelectFieldOptionDefinition> getSelectFieldOptionDefinition()
Get the list of SelectFieldOptionDefinition. If options is not empty, took the options defined in this field definition. Else, if path is not empty, build an options list based on the node refereed by the path and property value. Else nothing is define, return an empty option. Default value and i18n of the Label is also part of the responsibility of this method.


getIconResource

public com.vaadin.server.Resource getIconResource(SelectFieldOptionDefinition option)
Default Implementation to retrieve an Icon. Sub class should override this method in order to retrieve others Resource.


setPropertyDataSourceAndDefaultValue

public void setPropertyDataSourceAndDefaultValue(com.vaadin.data.Property<?> property)
Make sure to set defaultValue whenever value is null and nullSelectionAllowed is false, i.e. not just for new node adapters.

Overrides:
setPropertyDataSourceAndDefaultValue in class AbstractFieldFactory<D extends SelectFieldDefinition,Object>

createDefaultValue

protected Object createDefaultValue(com.vaadin.data.Property<?> dataSource)
Set the value selected. Set selectedItem to the last stored value. If not yet stored, set initialSelectedKey as selectedItem Else, set the first element of the list.

Overrides:
createDefaultValue in class AbstractFieldFactory<D extends SelectFieldDefinition,Object>

getDefinitionType

protected Class<?> getDefinitionType()
Overrides:
getDefinitionType in class AbstractFieldFactory<D extends SelectFieldDefinition,Object>
Returns:
Class Type defined into the field definition or null if not defined.

createRemoteOptionFilterPredicate

protected org.apache.jackrabbit.commons.predicate.Predicate createRemoteOptionFilterPredicate()
Returns:
Predicate used to filter the remote children option nodes.

getRemoteOptionsName

protected String getRemoteOptionsName(javax.jcr.Node option,
                                      String propertyName)
                               throws javax.jcr.RepositoryException
Get the specific node property.
If this property is not defined, return the node name. Expose this method in order to let subclass define their own implementation.

Throws:
javax.jcr.RepositoryException

getRemoteOptionsValue

protected String getRemoteOptionsValue(javax.jcr.Node option,
                                       String propertyName)
                                throws javax.jcr.RepositoryException
Get the specific node property.
If this property is not defined, return the node name. Expose this method in order to let subclass define their own implementation.

Throws:
javax.jcr.RepositoryException


Copyright © 2014 Magnolia International Ltd.. All Rights Reserved.