org.alfresco.web.bean.generator
Class BaseComponentGenerator

java.lang.Object
  extended by org.alfresco.web.bean.generator.BaseComponentGenerator
All Implemented Interfaces:
IComponentGenerator
Direct Known Subclasses:
AjaxTagPickerGenerator, AssociationGenerator, CategorySelectorGenerator, CharsetSelectorGenerator, CheckboxGenerator, ChildAssociationGenerator, DatePickerGenerator, HtmlSeparatorGenerator, LabelGenerator, LanguageSelectorGenerator, LinkGenerator, MimeTypeSelectorGenerator, SpaceIconPickerGenerator, StoreSelectorGenerator, TextFieldGenerator

public abstract class BaseComponentGenerator
extends java.lang.Object
implements IComponentGenerator


Nested Class Summary
protected static class BaseComponentGenerator.ControlType
           
 
Constructor Summary
BaseComponentGenerator()
           
 
Method Summary
protected  void addStringConstraintParam(java.util.List params, java.lang.String param)
          Adds the given string parameter to the list of parameters to be used for validating constraints on the client.
protected  void createAndSetConverter(javax.faces.context.FacesContext context, java.lang.String converterId, javax.faces.component.UIComponent component)
          Creates the converter with the given id and adds it to the component.
protected  javax.faces.component.UIComponent createComponent(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item)
          Creates the component for the given proerty sheet item.
protected  javax.faces.component.UIOutput createOutputTextComponent(javax.faces.context.FacesContext context, java.lang.String id)
          Creates an output text component.
 javax.faces.component.UIComponent generateAndAdd(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item)
          Dynamically generates a component for the given property sheet item.
protected  org.alfresco.service.cmr.dictionary.AssociationDefinition getAssociationDefinition(javax.faces.context.FacesContext context, Node node, java.lang.String associationName)
          Retrieve the AssociationDefinition for the given property name on the given node
protected  BaseComponentGenerator.ControlType getControlType()
          Returns the type of the control being generated
protected  org.alfresco.service.cmr.dictionary.PropertyDefinition getPropertyDefinition(javax.faces.context.FacesContext context, Node node, java.lang.String propertyName)
          Retrieve the PropertyDefinition for the given property name on the given node
 boolean isEnabledInEditMode(javax.faces.context.FacesContext context, javax.faces.component.UIComponent control, org.alfresco.service.cmr.dictionary.PropertyDefinition propDef)
          Determines whether the component will be enabled when rendered.
protected  void setupAssociation(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item, org.alfresco.service.cmr.dictionary.AssociationDefinition associationDef, javax.faces.component.UIComponent component)
          Sets up the association component i.e.
protected  void setupConstraints(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem property, org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, javax.faces.component.UIComponent component)
          Sets up client validation rules for any constraints the property has.
protected  void setupConverter(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem association, org.alfresco.service.cmr.dictionary.AssociationDefinition associationDef, javax.faces.component.UIComponent component)
          Sets up the appropriate converter for the given association
protected  void setupConverter(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem property, org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, javax.faces.component.UIComponent component)
          Sets up the appropriate converter for the given property
protected  void setupMandatoryAssociationIfNecessary(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem association, org.alfresco.service.cmr.dictionary.AssociationDefinition associationDef, javax.faces.component.UIComponent component)
          Sets up a mandatory validation rule for the given association.
protected  void setupMandatoryMarker(javax.faces.context.FacesContext context, PropertySheetItem item)
          Sets up the marker to show that the item is mandatory.
protected  void setupMandatoryPropertyIfNecessary(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem property, org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, javax.faces.component.UIComponent component)
          Sets up a mandatory validation rule for the given property.
protected  void setupMandatoryValidation(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item, javax.faces.component.UIComponent component, boolean realTimeChecking, java.lang.String idSuffix)
          Sets up a client mandatory validation rule with the property sheet for the given item.
protected  javax.faces.component.UIComponent setupMultiValuePropertyIfNecessary(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem property, org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, javax.faces.component.UIComponent component)
          Creates a wrapper component around the given component to enable the user to edit multiple values.
protected  void setupNumericRangeConstraint(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem property, javax.faces.component.UIComponent component, org.alfresco.repo.dictionary.constraint.NumericRangeConstraint constraint, boolean realTimeChecking)
          Sets up a default validation rule for the numeric range constraint
protected  void setupProperty(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item, org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, javax.faces.component.UIComponent component)
          Sets up the property component i.e.
protected  void setupRegexConstraint(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem property, javax.faces.component.UIComponent component, org.alfresco.repo.dictionary.constraint.RegexConstraint constraint, boolean realTimeChecking)
          Sets up a default validation rule for the regular expression constraint
protected  void setupStringLengthConstraint(javax.faces.context.FacesContext context, UIPropertySheet propertySheet, PropertySheetItem property, javax.faces.component.UIComponent component, org.alfresco.repo.dictionary.constraint.StringLengthConstraint constraint, boolean realTimeChecking)
          Sets up a default validation rule for the string length constraint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.alfresco.web.bean.generator.IComponentGenerator
generate
 

Constructor Detail

BaseComponentGenerator

public BaseComponentGenerator()
Method Detail

generateAndAdd

public javax.faces.component.UIComponent generateAndAdd(javax.faces.context.FacesContext context,
                                                        UIPropertySheet propertySheet,
                                                        PropertySheetItem item)
Description copied from interface: IComponentGenerator
Dynamically generates a component for the given property sheet item. The generated component is also setup appropriately for it's model definition and added to the given property sheet.

Specified by:
generateAndAdd in interface IComponentGenerator
Parameters:
context - FacesContext
propertySheet - The property sheet component
item - The wrappper component representing the item to generate, either a property, association or child association
Returns:
The component instance

createComponent

protected javax.faces.component.UIComponent createComponent(javax.faces.context.FacesContext context,
                                                            UIPropertySheet propertySheet,
                                                            PropertySheetItem item)
Creates the component for the given proerty sheet item.

Parameters:
context - FacesContext
propertySheet - The property sheet being generated
item - The property or association being generated
Returns:
The newly created component

createAndSetConverter

protected void createAndSetConverter(javax.faces.context.FacesContext context,
                                     java.lang.String converterId,
                                     javax.faces.component.UIComponent component)
Creates the converter with the given id and adds it to the component.

Parameters:
context - FacesContext
converterId - The name of the converter to create
component - The component to add the converter to

createOutputTextComponent

protected javax.faces.component.UIOutput createOutputTextComponent(javax.faces.context.FacesContext context,
                                                                   java.lang.String id)
Creates an output text component.

Parameters:
context - FacesContext
id - Optional id to set
Returns:
The new component

setupProperty

protected void setupProperty(javax.faces.context.FacesContext context,
                             UIPropertySheet propertySheet,
                             PropertySheetItem item,
                             org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef,
                             javax.faces.component.UIComponent component)
Sets up the property component i.e. setting the value binding

Parameters:
context - FacesContext
propertySheet - The property sheet
item - The parent component
propertyDef - The property definition
component - The component representing the property

setupAssociation

protected void setupAssociation(javax.faces.context.FacesContext context,
                                UIPropertySheet propertySheet,
                                PropertySheetItem item,
                                org.alfresco.service.cmr.dictionary.AssociationDefinition associationDef,
                                javax.faces.component.UIComponent component)
Sets up the association component i.e. setting the value binding

Parameters:
context - FacesContext
propertySheet - The property sheet
item - The parent component
associationDef - The association definition
component - The component representing the association

setupMultiValuePropertyIfNecessary

protected javax.faces.component.UIComponent setupMultiValuePropertyIfNecessary(javax.faces.context.FacesContext context,
                                                                               UIPropertySheet propertySheet,
                                                                               PropertySheetItem property,
                                                                               org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef,
                                                                               javax.faces.component.UIComponent component)
Creates a wrapper component around the given component to enable the user to edit multiple values.

Parameters:
context - FacesContext
propertySheet - The property sheet being generated
property - The property being generated
propertyDef - The data dictionary definition for the property
component - The component representing the property
Returns:
A wrapped component if the property is multi-valued or the original component if it is not multi-valued

setupMandatoryPropertyIfNecessary

protected void setupMandatoryPropertyIfNecessary(javax.faces.context.FacesContext context,
                                                 UIPropertySheet propertySheet,
                                                 PropertySheetItem property,
                                                 org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef,
                                                 javax.faces.component.UIComponent component)
Sets up a mandatory validation rule for the given property.

Parameters:
context - FacesContext
propertySheet - The property sheet being generated
property - The property being generated
propertyDef - The data dictionary definition of the property
component - The component representing the property

setupMandatoryAssociationIfNecessary

protected void setupMandatoryAssociationIfNecessary(javax.faces.context.FacesContext context,
                                                    UIPropertySheet propertySheet,
                                                    PropertySheetItem association,
                                                    org.alfresco.service.cmr.dictionary.AssociationDefinition associationDef,
                                                    javax.faces.component.UIComponent component)
Sets up a mandatory validation rule for the given association.

Parameters:
context - FacesContext
propertySheet - The property sheet being generated
association - The association being generated
associationDef - The data dictionary definition of the association
component - The component representing the association

setupMandatoryValidation

protected void setupMandatoryValidation(javax.faces.context.FacesContext context,
                                        UIPropertySheet propertySheet,
                                        PropertySheetItem item,
                                        javax.faces.component.UIComponent component,
                                        boolean realTimeChecking,
                                        java.lang.String idSuffix)
Sets up a client mandatory validation rule with the property sheet for the given item.

Parameters:
context - FacesContext
propertySheet - The property sheet to add the validation rule to
item - The item being generated
component - The component representing the item
realTimeChecking - true to make the client validate as the user types
idSuffix - An optional suffix to add to the client id

setupMandatoryMarker

protected void setupMandatoryMarker(javax.faces.context.FacesContext context,
                                    PropertySheetItem item)
Sets up the marker to show that the item is mandatory.

Parameters:
context - FacesContext
item - The item being generated

setupConstraints

protected void setupConstraints(javax.faces.context.FacesContext context,
                                UIPropertySheet propertySheet,
                                PropertySheetItem property,
                                org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef,
                                javax.faces.component.UIComponent component)
Sets up client validation rules for any constraints the property has.

Parameters:
context - FacesContext propertySheet The property sheet being generated
property - The property being generated
propertyDef - The data dictionary definition of the property
component - The component representing the property

setupRegexConstraint

protected void setupRegexConstraint(javax.faces.context.FacesContext context,
                                    UIPropertySheet propertySheet,
                                    PropertySheetItem property,
                                    javax.faces.component.UIComponent component,
                                    org.alfresco.repo.dictionary.constraint.RegexConstraint constraint,
                                    boolean realTimeChecking)
Sets up a default validation rule for the regular expression constraint

Parameters:
context - FacesContext
propertySheet - The property sheet to add the validation rule to
property - The property being generated
component - The component representing the property
constraint - The constraint to setup
realTimeChecking - true to make the client validate as the user types

setupStringLengthConstraint

protected void setupStringLengthConstraint(javax.faces.context.FacesContext context,
                                           UIPropertySheet propertySheet,
                                           PropertySheetItem property,
                                           javax.faces.component.UIComponent component,
                                           org.alfresco.repo.dictionary.constraint.StringLengthConstraint constraint,
                                           boolean realTimeChecking)
Sets up a default validation rule for the string length constraint

Parameters:
context - FacesContext
propertySheet - The property sheet to add the validation rule to
property - The property being generated
component - The component representing the property
constraint - The constraint to setup
realTimeChecking - true to make the client validate as the user types

setupNumericRangeConstraint

protected void setupNumericRangeConstraint(javax.faces.context.FacesContext context,
                                           UIPropertySheet propertySheet,
                                           PropertySheetItem property,
                                           javax.faces.component.UIComponent component,
                                           org.alfresco.repo.dictionary.constraint.NumericRangeConstraint constraint,
                                           boolean realTimeChecking)
Sets up a default validation rule for the numeric range constraint

Parameters:
context - FacesContext
propertySheet - The property sheet to add the validation rule to
property - The property being generated
component - The component representing the property
constraint - The constraint to setup
realTimeChecking - true to make the client validate as the user types

setupConverter

protected void setupConverter(javax.faces.context.FacesContext context,
                              UIPropertySheet propertySheet,
                              PropertySheetItem property,
                              org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef,
                              javax.faces.component.UIComponent component)
Sets up the appropriate converter for the given property

Parameters:
context - FacesContext
propertySheet - The property sheet being generated
property - The property being generated
propertyDef - The data dictionary definition of the property
component - The component representing the property

setupConverter

protected void setupConverter(javax.faces.context.FacesContext context,
                              UIPropertySheet propertySheet,
                              PropertySheetItem association,
                              org.alfresco.service.cmr.dictionary.AssociationDefinition associationDef,
                              javax.faces.component.UIComponent component)
Sets up the appropriate converter for the given association

Parameters:
context - FacesContext
propertySheet - The property sheet being generated
association - The association being generated
associationDef - The data dictionary definition of the property
component - The component representing the association

getControlType

protected BaseComponentGenerator.ControlType getControlType()
Returns the type of the control being generated

Returns:
The type of the control either a FIELD or a SELECTOR

getPropertyDefinition

protected org.alfresco.service.cmr.dictionary.PropertyDefinition getPropertyDefinition(javax.faces.context.FacesContext context,
                                                                                       Node node,
                                                                                       java.lang.String propertyName)
Retrieve the PropertyDefinition for the given property name on the given node

Parameters:
node - The node to get the property definition from
propertyName - The name of the property
Returns:
PropertyDefinition for the node or null if a definition can not be found

getAssociationDefinition

protected org.alfresco.service.cmr.dictionary.AssociationDefinition getAssociationDefinition(javax.faces.context.FacesContext context,
                                                                                             Node node,
                                                                                             java.lang.String associationName)
Retrieve the AssociationDefinition for the given property name on the given node

Parameters:
node - The node to get the association definition from
associationName - The name of the property
Returns:
AssociationDefinition for the node or null if a definition can not be found

addStringConstraintParam

protected void addStringConstraintParam(java.util.List params,
                                        java.lang.String param)
Adds the given string parameter to the list of parameters to be used for validating constraints on the client. This method adds the quotes around the given parameter and also escapes any ocurrences of the double quote character.

Parameters:
params - The list of parameters for the constraint
param - The string parameter to add

isEnabledInEditMode

public boolean isEnabledInEditMode(javax.faces.context.FacesContext context,
                                   javax.faces.component.UIComponent control,
                                   org.alfresco.service.cmr.dictionary.PropertyDefinition propDef)
Description copied from interface: IComponentGenerator
Determines whether the component will be enabled when rendered.

Specified by:
isEnabledInEditMode in interface IComponentGenerator
Parameters:
context - FacesContext
control - The control being rendered
propDef - The definition of the property
Returns:
true if the component should be enabled


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.