org.enhydra.barracuda.contrib.dbroggisch.repopulation
Class ErrorFormMap

java.lang.Object
  extended byorg.enhydra.barracuda.core.forms.DefaultFormMap
      extended byorg.enhydra.barracuda.contrib.dbroggisch.repopulation.ErrorFormMap
All Implemented Interfaces:
FormMap, StateMap
Direct Known Subclasses:
RepopulationFormMap

public class ErrorFormMap
extends DefaultFormMap

Author:
Diez B. Roggisch This class eases the population of errors resulting from form-validation. This is done by catching raised exceptions and if their sources are FormElements, a mapping is made which consists of the static ERROR_PREFIX and the FormElements name to a BComponent.

If the Exception has set a text, the mapped component is a BText-component with that text. Otherwise it's just a BComponent.

When using this class, you should do two things:

  1. Subclass it and implement the TemplateModel-interface
  2. Add ERROR_PREFIX + Element-names directives to your HTML-code, e.g Dir::Get_Data.ModelName.e_Password
When processing the BTemplate, these directives will return null for elements without errors, resulting in discarding the nodes. Or they return the associated components so the nodes stay, and text will be substituted.

Field Summary
static String ERROR_PREFIX
           
protected static org.apache.log4j.Logger logger
           
 
Fields inherited from class org.enhydra.barracuda.core.forms.DefaultFormMap
defaultLoc, elements, localLogger, statemap, validators
 
Constructor Summary
ErrorFormMap()
           
 
Method Summary
 void addErrorComponent(String key, BComponent comp)
          If you want errors from whole-form-validation to be populated, simply use this as a convenient method to add mappings.
 Object getErrorComponent(String key)
          In your subclasses TemplateModel-interface call this.
 FormMap validate(boolean deferExceptions)
          Validate the entire form (both form level and elements).
 
Methods inherited from class org.enhydra.barracuda.core.forms.DefaultFormMap
clearState, defineElement, defineElement, defineValidator, exists, getBooleanVal, getBooleanVal, getDateVal, getDateVal, getDoubleVal, getDoubleVal, getElement, getElements, getElementVals, getFloatVal, getFloatVal, getIntegerVal, getIntegerVal, getLongVal, getLongVal, getShortVal, getShortVal, getState, getStateKeys, getStateValues, getStringVal, getStringVal, getVal, getVals, isNull, map, map, map, map, map, map, map, map, mapElement, mapElement, putState, removeState, setVal, validateElements, validateForm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR_PREFIX

public static String ERROR_PREFIX

logger

protected static final org.apache.log4j.Logger logger
Constructor Detail

ErrorFormMap

public ErrorFormMap()
Method Detail

validate

public FormMap validate(boolean deferExceptions)
                 throws ValidationException
Description copied from class: DefaultFormMap
Validate the entire form (both form level and elements). We start by invoking form validators which apply to individual form elements, then we invoke any which apply to the entire form

Specified by:
validate in interface FormMap
Overrides:
validate in class DefaultFormMap
Parameters:
deferExceptions - do we want to deferValidation exceptions and attempt to validate all elements so that we can process all the exceptions at once
Returns:
a reference to the FormMap (we do this so you can inline map/validate requests if you desire: form.map(req).validate())
Throws:
ValidationException - if the form (or any element within it) is invalid

addErrorComponent

public void addErrorComponent(String key,
                              BComponent comp)
If you want errors from whole-form-validation to be populated, simply use this as a convenient method to add mappings.


getErrorComponent

public Object getErrorComponent(String key)
In your subclasses TemplateModel-interface call this.



Copyright © 2003 BarracudaMVC.org All Rights Reserved.