pl.aislib.fm
Class Form

java.lang.Object
  extended bypl.aislib.fm.FieldContainer
      extended bypl.aislib.fm.Form

public class Form
extends FieldContainer

Class of forms. A form is a set of fields together with a set of rules. Form is said to be validated if all fields and rules are appropriately validated.

Since:
AISLIB 0.1
Version:
$Revision: 1.8 $
Author:
Michal Jastak, AIS.PL
Tomasz Pik, AIS.PL
Wojciech Swiatek, AIS.PL

Field Summary
static java.lang.String MC_ENTITY_RULE
           
protected  java.util.Map rules
          Map of rules.
protected  java.util.Map validatedRules
          Map of rule names and booleans.
 
Fields inherited from class pl.aislib.fm.FieldContainer
bTreatEmptyAsNull, fields, lang, log, MC_ENTITY_DYNAMIC_COUNT, MC_ENTITY_DYNAMIC_NUMBER_FROM_0, MC_ENTITY_DYNAMIC_NUMBER_FROM_1, MC_ENTITY_FORM, MC_ENTITY_GENERIC_NAME, MC_ENTITY_NAME, MC_ENTITY_NAME_SUFFIX, MC_ENTITY_OBJECT, MC_ENTITY_ORIGINAL_VALUE, MC_ENTITY_VALIDATOR, MC_ENTITY_VALUE, messageGroups, messages, messagesMap, name, orderedMessagesMap, originalValues, validatedFields, validators, values
 
Constructor Summary
Form(java.lang.String name)
           
 
Method Summary
 void addRule(Rule rule)
           
protected  void addSpecificEntityProperties(IEntity entity, java.lang.String entityName, java.util.Map entityProperties)
          Adds specific entity properties to given map.
protected  boolean checkRuleForValidation(Rule rule)
           
protected  java.lang.Object clone()
           
protected  boolean doValidate(java.util.Map fieldValues, java.lang.Object data)
          Form validates all non-complex fields first, then all complex fields.
protected  java.util.List getDynamicEntityNamesList(java.lang.String entityName)
           
protected  java.util.Map getEntitiesProperties()
           
protected  IEntity getEntity(java.lang.String entityName)
           
 java.util.Iterator getErrorCodes()
          This method will not work for dynamic fields.
 java.util.Map getErrorMessages(IMessageConverter messageConverter)
           
 Rule getRule(java.lang.String ruleName)
           
 java.util.Iterator getRuleNames()
           
 java.util.Map getValidatedRules()
           
 boolean isRuleValidated(java.lang.String ruleName)
           
protected  boolean preValidate(java.util.Map fieldValues, java.lang.Object data)
          Contains all necessary steps taken before the proper validation of fields in the container.
 void setConditionalFields()
          Automatically generates all conditional fields.
 java.lang.String toString()
           
protected  boolean validateRule(Rule rule, java.util.Map fieldValues, java.util.Map values)
           
protected  boolean validateRules(java.util.Map fieldValues)
           
 
Methods inherited from class pl.aislib.fm.FieldContainer
addField, constrainValues, constrainValues, getDynamicEntityNames, getDynamicNumbers, getEntityMessages, getEntityProperties, getErrorMessage, getErrorMessages, getErrorMessages, getField, getFieldNames, getMessageCode, getMessageCodes, getName, getOriginalValue, getOriginalValues, getStringValues, getValidatedFields, getValidators, getValue, getValue, getValues, getValues, isFieldValidated, isValueEmpty, orderFieldValues, postValidate, setLog, stamp, treatEmptyAsNull, validate, validate, validateComplexFields, validateField, validateField, validateField, validateNonComplexFields
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MC_ENTITY_RULE

public static final java.lang.String MC_ENTITY_RULE
See Also:
Constant Field Values

rules

protected java.util.Map rules
Map of rules.


validatedRules

protected java.util.Map validatedRules
Map of rule names and booleans.

Constructor Detail

Form

public Form(java.lang.String name)
See Also:
FieldContainer.FieldContainer(String)
Method Detail

addRule

public void addRule(Rule rule)
Parameters:
rule - Rule object.

checkRuleForValidation

protected boolean checkRuleForValidation(Rule rule)
Parameters:
rule - Rule object.
Returns:
true if the rule can be validated.

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException
See Also:
Object.clone()

doValidate

protected boolean doValidate(java.util.Map fieldValues,
                             java.lang.Object data)
Form validates all non-complex fields first, then all complex fields. Then it tries to validate all rules.

Specified by:
doValidate in class FieldContainer
Parameters:
fieldValues - map of field values.
data - an object specific for validators.
Returns:
true if all fields have been successfully validated.
See Also:
FieldContainer.doValidate(Map, Object)

validateRule

protected boolean validateRule(Rule rule,
                               java.util.Map fieldValues,
                               java.util.Map values)
Parameters:
rule - a Rule object
fieldValues - map of string field values.
values - map of values.
Returns:
true if rule has been successfully validated.

validateRules

protected boolean validateRules(java.util.Map fieldValues)
Parameters:
fieldValues - map of string field values.
Returns:
true if all rules have been successfully validated.

setConditionalFields

public void setConditionalFields()
Automatically generates all conditional fields.

The algorithm is as follows:


toString

public java.lang.String toString()
Returns:
description of the form.

getErrorCodes

public java.util.Iterator getErrorCodes()
This method will not work for dynamic fields. Therefore I would like to make it deprecated - wswiatek.

Overrides:
getErrorCodes in class FieldContainer
Returns:
iterator of message codes.
See Also:
FieldContainer.getErrorCodes()

getRuleNames

public java.util.Iterator getRuleNames()
Returns:
iterator of rule names.

getRule

public Rule getRule(java.lang.String ruleName)
Parameters:
ruleName - name of a rule.
Returns:
the rule.

getValidatedRules

public java.util.Map getValidatedRules()
Returns:
map of validated rules.

isRuleValidated

public boolean isRuleValidated(java.lang.String ruleName)
Parameters:
ruleName - name of a rule.
Returns:
true if the rule has been validated successfully.

preValidate

protected boolean preValidate(java.util.Map fieldValues,
                              java.lang.Object data)
Description copied from class: FieldContainer
Contains all necessary steps taken before the proper validation of fields in the container.

Overrides:
preValidate in class FieldContainer
Parameters:
fieldValues - map of field values.
data - an object specific for validators.
Returns:
true if all fields have been successfully pre-validated.
See Also:
FieldContainer.preValidate(Map, Object)

getEntity

protected IEntity getEntity(java.lang.String entityName)
Overrides:
getEntity in class FieldContainer
Parameters:
entityName - name of an entity.
Returns:
the entity.
See Also:
FieldContainer.getEntity(String)

getDynamicEntityNamesList

protected java.util.List getDynamicEntityNamesList(java.lang.String entityName)
Overrides:
getDynamicEntityNamesList in class FieldContainer
Parameters:
entityName - name of a dynamic entity.
Returns:
list of all names of entity's instances.
See Also:
FieldContainer.getDynamicEntityNamesList(String)

getErrorMessages

public java.util.Map getErrorMessages(IMessageConverter messageConverter)
Overrides:
getErrorMessages in class FieldContainer
See Also:
FieldContainer.getErrorMessages(IMessageConverter)

getEntitiesProperties

protected java.util.Map getEntitiesProperties()
Overrides:
getEntitiesProperties in class FieldContainer
See Also:
FieldContainer.getEntitiesProperties()

addSpecificEntityProperties

protected void addSpecificEntityProperties(IEntity entity,
                                           java.lang.String entityName,
                                           java.util.Map entityProperties)
Description copied from class: FieldContainer
Adds specific entity properties to given map.

Overrides:
addSpecificEntityProperties in class FieldContainer
Parameters:
entity - IEntity object.
entityName - name of entity.
entityProperties - not nullable Map of entity properties.
See Also:
FieldContainer.addSpecificEntityProperties(pl.aislib.fm.forms.IEntity, java.lang.String, java.util.Map)


Copyright © 2002-2005 AIS.PL. All Rights Reserved.