org.apache.myfaces.extensions.validator.core.initializer.component
Class AbstractHtmlCoreComponentsComponentInitializer

java.lang.Object
  extended by org.apache.myfaces.extensions.validator.core.initializer.component.AbstractHtmlCoreComponentsComponentInitializer
All Implemented Interfaces:
ComponentInitializer

public abstract class AbstractHtmlCoreComponentsComponentInitializer
extends Object
implements ComponentInitializer

Basic implementation of a ComponentInitializer which allows an easier handling of required validations and provides a default implementation for standard components.

Since:
x.x.3
Author:
Gerhard Petracek

Constructor Summary
AbstractHtmlCoreComponentsComponentInitializer()
           
 
Method Summary
 void configureComponent(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, Map<String,Object> metaData)
          If the component is one of the standard input components, the max length attribute is configured and the required attribute is configured (if empty field validation and required initialization is activated)
protected  void configureMaxLengthAttribute(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, Map<String,Object> metaData)
          This default implementation uses the transformed meta-data stored via the (CommonMetaDataKeys.MAX_LENGTH key for initializing e.g. the maxLength attribute of the current component (of type HtmlInputText or HtmlInputSecret.
protected abstract  void configureRequiredAttribute(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, Map<String,Object> metaData)
          The concrete implementation has to initialize the component based on the given meta-data map.
protected  boolean isRequiredInitializationActive()
          Uses the config introduced by prev.
protected  boolean isRequiredInitializationSupported(javax.faces.component.UIComponent uiComponent)
          if there is no special attribute at the component which should overrule the annotated property return true!
protected  boolean processComponent(javax.faces.component.UIComponent uiComponent)
          Activates the implementation for special components (-> other components will be ignored).
protected  boolean validateEmptyFields()
          Uses the config introduced by JSF 2 for specifying if fields without content should be available for required validation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractHtmlCoreComponentsComponentInitializer

public AbstractHtmlCoreComponentsComponentInitializer()
Method Detail

configureComponent

public void configureComponent(javax.faces.context.FacesContext facesContext,
                               javax.faces.component.UIComponent uiComponent,
                               Map<String,Object> metaData)
If the component is one of the standard input components, the max length attribute is configured and the required attribute is configured (if empty field validation and required initialization is activated)

Specified by:
configureComponent in interface ComponentInitializer
Parameters:
facesContext - The JSF Context
uiComponent - The component which should be initialised
metaData - map which contains the transformed meta-data

validateEmptyFields

protected boolean validateEmptyFields()
Uses the config introduced by JSF 2 for specifying if fields without content should be available for required validation.

Returns:
true if fields with empty values should be validated, false otherwise.

isRequiredInitializationActive

protected boolean isRequiredInitializationActive()
Uses the config introduced by prev. ExtVal versions for specifying if required initialization should be used (it's useful e.g. for client-side validations provided by libs like trinidad).

Returns:
true if ExtVal should transfer meta-data for required fields to the component

configureRequiredAttribute

protected abstract void configureRequiredAttribute(javax.faces.context.FacesContext facesContext,
                                                   javax.faces.component.UIComponent uiComponent,
                                                   Map<String,Object> metaData)
The concrete implementation has to initialize the component based on the given meta-data map. This method is only called if all pre-conditions are fulfilled.

Parameters:
facesContext - The JSF Context
uiComponent - The UIComponent which should be configured.
metaData - map which contains the transformed meta-data

processComponent

protected boolean processComponent(javax.faces.component.UIComponent uiComponent)
Activates the implementation for special components (-> other components will be ignored).

Parameters:
uiComponent - The UIComponent which should be configured.
Returns:
Should the component be initialized.

isRequiredInitializationSupported

protected boolean isRequiredInitializationSupported(javax.faces.component.UIComponent uiComponent)
if there is no special attribute at the component which should overrule the annotated property return true!

Parameters:
uiComponent - component which implements the EditableValueHolder interface
Returns:
false to overrule the annotated property e.g. if component is readonly

configureMaxLengthAttribute

protected void configureMaxLengthAttribute(javax.faces.context.FacesContext facesContext,
                                           javax.faces.component.UIComponent uiComponent,
                                           Map<String,Object> metaData)
This default implementation uses the transformed meta-data stored via the (CommonMetaDataKeys.MAX_LENGTH key for initializing e.g. the maxLength attribute of the current component (of type HtmlInputText or HtmlInputSecret.

Parameters:
facesContext - The JSF Context
uiComponent - The component to configure.
metaData - map which contains the transformed meta-data


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.