public interface UIComponentFactory
Modifier and Type | Field and Description |
---|---|
static String |
REQUIRED_STYLE_NAME
HTML Style class for required input components
|
Modifier and Type | Method and Description |
---|---|
void |
addErrorMessagesToComponents(Map<UIComponent,List<String>> errorMessages)
Default implementation simply uses
UIComponents.addComponentError(com.whitestein.lsps.vaadin.ui.components.UIComponent, String) to attach error messages to Vaadin components. |
void |
afterCreate(UIComponent component)
Perform standard set of behaviors when component is created.
|
void |
applyCommonProperties(UIComponent component)
Applies all standard properties from the component definition to the
given input component.
|
void |
applyListeners(UIComponent component)
Applies all listeners defined in the component definition associated with the
given component.
|
UIComponent |
createComponent(LspsScreen screen,
UIComponent parent,
RecordHolder definition,
UIComponentScope scope)
Creates and injects component based on the provided component definition.
|
com.vaadin.data.util.converter.Converter<?,?> |
createConverterForRenderer(UIGrid owner,
Variant.RecordVariant rendererDef)
Optionally a converter may be used together with a renderer, to convert LSPS types to Java objects as expected by the renderer.
|
com.vaadin.ui.Field<?> |
createEditor(Variant.RecordVariant editorDef,
Type type)
Instantiates an editor field based on the editor definition record
and the value type.
|
UIListenerAction |
createListenerAction(UIScreen screen,
UIListener listener,
RecordHolder definition,
UIComponent scope)
Creates listener action based on the provided definition.
|
String |
getErrorMessage(Variant.RecordVariant validationError,
UIComponent scope)
Retrieves the error message from the "ui::ValidationError" record.
|
Injector |
getInjector()
Returns instance of
Injector to use for injecting created components |
Map<UIComponent,List<String>> |
mapErrorsToComponents(LspsScreen screen,
LspsFormConnector.ValidationErrors validationErrors,
Bindings bindings)
Takes a set of validation errors and shows them on components in given screen.
|
void |
refresh(UIComponent component)
Refreshes the UI component.
|
void |
updateComponentCaption(UIComponent component)
Sets caption property for the given component based on value of field
UIFieldNames.LABEL . |
void |
updateHints(UIComponent component,
Variant.MapVariant<String,Object> newHints,
Variant.MapVariant<String,Object> oldHints)
Applies all hints defined in the component definition associated with the
given component.
|
static final String REQUIRED_STYLE_NAME
UIComponent createComponent(LspsScreen screen, UIComponent parent, RecordHolder definition, UIComponentScope scope)
screen
- containing screen, ignored if parent is not null.parent
- parent of the component in the UI component hierarchy, null if root.definition
- definition of the component to create, not null.scope
- component scope; if null, same scope as parent will be usedvoid afterCreate(UIComponent component)
createComponent(LspsScreen, UIComponent, RecordHolder, UIComponentScope)
, after the component is created.
If the component implements Field
, it's switched to buffered mode
so that conversion/validation of the field value is properly integrated
with the LSPS UI lifecycle.component
- void updateHints(UIComponent component, Variant.MapVariant<String,Object> newHints, Variant.MapVariant<String,Object> oldHints)
UIComponent.refresh()
.component
- component to apply hints fornewHints
- new presentation hints, never null, never absent.oldHints
- old presentation hints, never null, never absent.void applyCommonProperties(UIComponent component)
UIFieldNames.READ_ONLY
- sets read only for the given component (Component.setEnabled(boolean)
)UIFieldNames.TRIGGER_PROCESSING_ON_CHANGE
- sets immediate property (AbstractComponent.setImmediate(boolean)
)UIFieldNames.REQUIRED
- adds required style class (REQUIRED_STYLE_NAME
) if the field value is true)UIFieldNames.LABEL
- calls updateComponentCaption(UIComponent)
UIFieldNames.HELP_TEXT
- sets help text property (AbstractComponent.setDescription(String)
)UIFieldNames.PLACEHOLDER
- sets input prompt property (AbstractTextField.setInputPrompt(String)
)component
- void updateComponentCaption(UIComponent component)
UIFieldNames.LABEL
.component
- sets caption property (AbstractComponent.setCaption(String)
)void applyListeners(UIComponent component)
component
- the component, not null.UIListenerAction createListenerAction(UIScreen screen, UIListener listener, RecordHolder definition, UIComponent scope)
screen
- containing screenlistener
- listener where this action is defined. Not null.definition
- definition of the listener action. Not null. Must be a subtype of ui::Action.scope
- run handle in this scope, not null.Map<UIComponent,List<String>> mapErrorsToComponents(LspsScreen screen, LspsFormConnector.ValidationErrors validationErrors, Bindings bindings)
addErrorMessagesToComponents(java.util.Map)
to do that.
The specification of the algorithm is present in Workpackage 039: https://inside.whitestein.com/mediawiki/inside/LSPS:WP-039screen
- the containing screen, not null.validationErrors
- not null. A set of "ui::ValidationError" records produced by validations during last event process pass. Never null.bindings
- never null. The algorithm may use this map to find components displaying particular record property.void addErrorMessagesToComponents(Map<UIComponent,List<String>> errorMessages)
UIComponents.addComponentError(com.whitestein.lsps.vaadin.ui.components.UIComponent, String)
to attach error messages to Vaadin components.
Override to show error messages in different way, e.g. mark the components with a custom CSS style.
All error messages on all components must be cleared prior running this method - this method does not clear previous error messages.
If you are adding custom CSS styles, you must manually clear the styles on all components.
To get the list of all components, use AbstractScreen.getAllComponents()
.errorMessages
- maps vaadin components to a list of error messages which should be displayed. Never null, may be empty.String getErrorMessage(Variant.RecordVariant validationError, UIComponent scope)
validationError
- an instance of "ui::ValidationError" record, not null.scope
- the error record was produced by listener executing in this scope. Not null.void refresh(UIComponent component)
UIComponent.refresh()
.component
- the component, not null.com.vaadin.data.util.converter.Converter<?,?> createConverterForRenderer(UIGrid owner, Variant.RecordVariant rendererDef)
owner
- the grid that will use the rendererrendererDef
- the renderer definition, not null.com.vaadin.ui.Field<?> createEditor(Variant.RecordVariant editorDef, Type type)
Instantiates an editor field based on the editor definition record and the value type. The instantiated editor field allows to edit grid values.
The editors are used by the Grid component when editing grid values.
editorDef
- type
- the type of the valuenull
Copyright © 2007-2018 Whitestein Technologies. All Rights Reserved.