cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r448035 [1/2] - in /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel: ./ library/ tree/builder/
Date Wed, 20 Sep 2006 02:48:03 GMT
Author: vgritsenko
Date: Tue Sep 19 19:48:01 2006
New Revision: 448035

URL: http://svn.apache.org/viewvc?view=rev&rev=448035
Log:
use locatable exceptions

Modified:
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateField.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanField.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Field.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FormDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueField.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/NewDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Repeater.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/Library.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/JavaTreeModelDefinitionBuilder.java
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java Tue Sep 19 19:48:01 2006
@@ -19,6 +19,8 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.cocoon.forms.FormsException;
+
 /**
  * The {@link AbstractContainerDefinition} corresponding to an {@link AbstractContainerWidget}.
  *
@@ -48,18 +50,19 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof AbstractContainerDefinition) {
-            AbstractContainerDefinition other = (AbstractContainerDefinition) definition;
-
-            Iterator i = other.definitions.getWidgetDefinitions().iterator();
-            while(i.hasNext()) {
-                try {
-                    WidgetDefinition def = (WidgetDefinition) i.next();
-                    this.definitions.addWidgetDefinition(def);
-                } catch (DuplicateIdException e) { /* ignored */ }
-            }
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
+        if (!(definition instanceof AbstractContainerDefinition)) {
+            throw new FormsException("Parent definition " + definition.getClass().getName() + " is not an AbstractContainerDefinition.",
+                                     getLocation());
+        }
+
+        AbstractContainerDefinition other = (AbstractContainerDefinition) definition;
+
+        Iterator i = other.definitions.getWidgetDefinitions().iterator();
+        while(i.hasNext()) {
+            try {
+                WidgetDefinition def = (WidgetDefinition) i.next();
+                this.definitions.addWidgetDefinition(def);
+            } catch (DuplicateIdException e) { /* ignored */ }
         }
     }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -55,8 +55,8 @@
                 } else if ((def = definition.getWidgetDefinition(newId)) != null) {
                     this.context.setSuperDefinition(def);
                 }
-                // throw new Exception("Widget to inherit from ("+newId+") not
-                // found! (at "+DomHelper.getLocation(element)+")");
+                // throw new FormsException("Widget to inherit from ("+newId+") not
+                // found!", DomHelper.getLocationObject(element));
             }
 
             WidgetDefinition widgetDefinition = buildAnotherWidgetDefinition(widgetElement);

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java Tue Sep 19 19:48:01 2006
@@ -25,6 +25,8 @@
 import org.apache.cocoon.forms.event.ValueChangedEvent;
 import org.apache.cocoon.forms.event.ValueChangedListener;
 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
+import org.apache.cocoon.forms.FormsException;
+import org.apache.cocoon.forms.FormsRuntimeException;
 
 /**
  * Base class for WidgetDefinitions that use a Datatype and SelectionList.
@@ -63,15 +65,17 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof AbstractDatatypeWidgetDefinition) {
-            AbstractDatatypeWidgetDefinition other = (AbstractDatatypeWidgetDefinition) definition;
-            this.datatype = other.datatype;
-            this.initialValue = other.initialValue;
-            this.selectionList = other.selectionList;
-            this.listener = other.listener;
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
+        if (!(definition instanceof AbstractDatatypeWidgetDefinition)) {
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not an AbstractDatatypeWidgetDefinition.",
+                                     getLocation());
         }
+
+        AbstractDatatypeWidgetDefinition other = (AbstractDatatypeWidgetDefinition) definition;
+
+        this.datatype = other.datatype;
+        this.initialValue = other.initialValue;
+        this.selectionList = other.selectionList;
+        this.listener = other.listener;
     }
 
     public Datatype getDatatype() {
@@ -91,7 +95,8 @@
     public void setSelectionList(SelectionList selectionList) {
         checkMutable();
         if (selectionList != null && selectionList.getDatatype() != getDatatype()) {
-            throw new RuntimeException("Tried to assign a SelectionList that is not associated with this widget's datatype.");
+            throw new FormsRuntimeException("Tried to assign a selection list that is not associated with this widget's datatype.",
+                                            getLocation());
         }
         this.selectionList = selectionList;
     }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -101,8 +101,8 @@
         Element selectionListElement = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, name);
 
         if (selectionListElement != null && definition.getDatatype() == null) {
-            throw new Exception("A widget with a selection list always requires a datatype as well! (at " +
-                                DomHelper.getLocation(selectionListElement) + " )");
+            throw new FormsException("A widget with a selection list requires a datatype.",
+                                     DomHelper.getLocationObject(widgetElement));
         }
 
         if (selectionListElement == null) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java Tue Sep 19 19:48:01 2006
@@ -30,6 +30,7 @@
 import org.apache.cocoon.forms.validation.WidgetValidator;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.xml.AttributesImpl;
+
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -273,11 +274,11 @@
     }
 
     public Object getValue() {
-        throw new UnsupportedOperationException("Widget " + toString() + " has no value, at " + getLocation());
+        throw new UnsupportedOperationException("Widget " + this + " has no value, at " + getLocation());
     }
 
     public void setValue(Object object) {
-        throw new UnsupportedOperationException("Widget " + toString() + " has no value, at " + getLocation());
+        throw new UnsupportedOperationException("Widget " + this + " has no value, at " + getLocation());
     }
 
     public boolean isRequired() {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java Tue Sep 19 19:48:01 2006
@@ -21,7 +21,10 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.excalibur.xml.sax.XMLizable;
+
 import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.CreateEvent;
 import org.apache.cocoon.forms.event.CreateListener;
 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
@@ -29,7 +32,7 @@
 import org.apache.cocoon.forms.validation.WidgetValidator;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.xml.XMLUtils;
-import org.apache.excalibur.xml.sax.XMLizable;
+
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -87,33 +90,34 @@
      * initialize this definition with the other, sort of like a copy constructor
      */
     public void initializeFrom(WidgetDefinition definition) throws Exception {
-        if (definition instanceof AbstractWidgetDefinition) {
-            AbstractWidgetDefinition other = (AbstractWidgetDefinition) definition;
+        if (!(definition instanceof AbstractWidgetDefinition)) {
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not an AbstractWidgetDefinition.",
+                                     getLocation());
+        }
 
-            this.state = other.state;
-            this.createListener = other.createListener; // this works, we don't really remove listeners, right?
+        AbstractWidgetDefinition other = (AbstractWidgetDefinition) definition;
 
-            this.validators = new ArrayList();
-            if (other.validators != null) {
-                for (int i = 0; i < other.validators.size(); i++) {
-                    this.validators.add(other.validators.get(i));
-                }
+        this.state = other.state;
+        this.createListener = other.createListener; // this works, we don't really remove listeners, right?
+
+        this.validators = new ArrayList();
+        if (other.validators != null) {
+            for (int i = 0; i < other.validators.size(); i++) {
+                this.validators.add(other.validators.get(i));
             }
+        }
 
-            if (other.attributes != null) {
-                if (attributes == null) {
-                    attributes = new HashMap();
-                }
-                attributes.putAll(other.attributes);
+        if (other.attributes != null) {
+            if (attributes == null) {
+                attributes = new HashMap();
             }
-            if (other.displayData != null) {
-                if (displayData == null) {
-                    displayData = new HashMap();
-                }
-                displayData.putAll(other.displayData);
+            attributes.putAll(other.attributes);
+        }
+        if (other.displayData != null) {
+            if (displayData == null) {
+                displayData = new HashMap();
             }
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
+            displayData.putAll(other.displayData);
         }
     }
 
@@ -277,7 +281,7 @@
     public void generateDisplayData(String name, ContentHandler contentHandler) throws SAXException {
         Object data = this.displayData.get(name);
         if (data != null) {
-            ((XMLizable)data).toSAX(contentHandler);
+            ((XMLizable) data).toSAX(contentHandler);
         } else if (!this.displayData.containsKey(name)) {
             throw new IllegalArgumentException("Unknown display data name '" + name + "'");
         }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -22,13 +22,15 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.CascadingException;
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.avalon.framework.service.Serviceable;
+import org.apache.excalibur.xml.sax.XMLizable;
+
 import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.datatype.DatatypeManager;
 import org.apache.cocoon.forms.event.CreateListener;
 import org.apache.cocoon.forms.event.WidgetListener;
@@ -36,7 +38,7 @@
 import org.apache.cocoon.forms.expression.ExpressionManager;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.apache.cocoon.forms.validation.WidgetValidatorBuilder;
-import org.apache.excalibur.xml.sax.XMLizable;
+
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -122,14 +124,14 @@
         } else {
             String id = DomHelper.getAttribute(widgetElement, "id");
             if (id.indexOf('/') != -1 || id.indexOf('.') != -1) {
-                throw new Exception("A widget name cannot contain '.' or '/' as this conflicts with widget paths, at " +
-                                    DomHelper.getLocation(widgetElement));
+                throw new FormsException("A widget name cannot contain '.' or '/' as this conflicts with widget paths.",
+                                         DomHelper.getLocationObject(widgetElement));
             }
             // NewDefinitions are allowed to have a : in their id because they can look up
             // class widgets from the library directly
             if (id.indexOf(':') != -1 && !(widgetDefinition instanceof NewDefinition)) {
-                throw new Exception("A widget name cannot contain ':' as this conflicts with library prefixes, at " +
-                                    DomHelper.getLocation(widgetElement));
+                throw new FormsException("A widget name cannot contain ':' as this conflicts with library prefixes",
+                                         DomHelper.getLocationObject(widgetElement));
             }
             widgetDefinition.setId(id);
         }
@@ -139,8 +141,8 @@
         if (stateValue != null) {
             WidgetState state = WidgetState.stateForName(stateValue);
             if (state == null) {
-                throw new Exception ("Unknown value '" + stateValue +"' for state attribute at " +
-                                     DomHelper.getLocation(widgetElement));
+                throw new FormsException("Unknown value '" + stateValue +"' for state attribute.",
+                                         DomHelper.getLocationObject(widgetElement));
             }
             widgetDefinition.setState(state);
         }
@@ -168,8 +170,8 @@
         try {
             builder = (WidgetDefinitionBuilder)widgetDefinitionBuilderSelector.select(widgetName);
         } catch (ServiceException e) {
-            throw new CascadingException("Unknown kind of widget '" + widgetName + "' at " +
-                                         DomHelper.getLocation(widgetDefinition), e);
+            throw new FormsException("Unknown kind of widget '" + widgetName + "'.",
+                                     e, DomHelper.getLocationObject(widgetDefinition));
         }
 
         return builder.buildWidgetDefinition(widgetDefinition, this.context);
@@ -188,8 +190,8 @@
                     try {
                         builder = (WidgetListenerBuilder) widgetListenerBuilderSelector.select(listenerElement.getLocalName());
                     } catch (ServiceException e) {
-                        throw new CascadingException("Unknown kind of eventlistener '" + listenerElement.getLocalName() +
-                                                     "' at " + DomHelper.getLocation(listenerElement), e);
+                        throw new FormsException("Unknown kind of eventlistener '" + listenerElement.getLocalName() + "'.", e,
+                                                 DomHelper.getLocationObject(listenerElement));
                     }
                     WidgetListener listener = builder.buildListener(listenerElement, listenerClass);
                     widgetListenerBuilderSelector.release(builder);
@@ -236,8 +238,8 @@
                     try {
                         builder = (WidgetValidatorBuilder)this.widgetValidatorBuilderSelector.select(name);
                     } catch(ServiceException e) {
-                        throw new CascadingException("Unknown kind of validator '" + name + "' at " +
-                                                     DomHelper.getLocation(element), e);
+                        throw new FormsException("Unknown kind of validator '" + name + "'.",
+                                                 e, DomHelper.getLocationObject(element));
                     }
 
                     widgetDefinition.addValidator(builder.build(element, widgetDefinition));

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java Tue Sep 19 19:48:01 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.ActionEvent;
 import org.apache.cocoon.forms.event.ActionListener;
 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
@@ -38,15 +39,15 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof ActionDefinition) {
-            ActionDefinition other = (ActionDefinition) definition;
+        if (!(definition instanceof ActionDefinition)) {
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not an ActionDefinition.",
+                                     getLocation());
+        }
 
-            this.actionCommand = other.actionCommand;
-            this.listener = other.listener;
+        ActionDefinition other = (ActionDefinition) definition;
 
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
-        }
+        this.actionCommand = other.actionCommand;
+        this.listener = other.listener;
     }
 
     public String getActionCommand() {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateField.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateField.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateField.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateField.java Tue Sep 19 19:48:01 2006
@@ -21,12 +21,15 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.cocoon.forms.FormsConstants;
+import org.apache.excalibur.xml.sax.XMLizable;
+
 import org.apache.cocoon.forms.FormContext;
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.FormsRuntimeException;
 import org.apache.cocoon.forms.formmodel.AggregateFieldDefinition.SplitMapping;
 import org.apache.cocoon.forms.util.I18nMessage;
 import org.apache.cocoon.forms.validation.ValidationError;
-import org.apache.excalibur.xml.sax.XMLizable;
+
 import org.apache.oro.text.regex.MatchResult;
 import org.apache.oro.text.regex.PatternMatcher;
 import org.apache.oro.text.regex.Perl5Matcher;
@@ -87,7 +90,7 @@
         if (!(widget instanceof Field)) {
             throw new IllegalArgumentException("AggregateField can only contain fields.");
         }
-        addField((Field)widget);
+        addField((Field) widget);
     }
 
     protected void addField(Field field) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java Tue Sep 19 19:48:01 2006
@@ -15,11 +15,6 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
-import org.apache.excalibur.xml.sax.XMLizable;
-import org.apache.oro.text.regex.Pattern;
-
-import org.outerj.expression.Expression;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -27,6 +22,14 @@
 import java.util.List;
 import java.util.Set;
 
+import org.apache.excalibur.xml.sax.XMLizable;
+
+import org.apache.cocoon.forms.FormsException;
+import org.apache.cocoon.forms.FormsRuntimeException;
+
+import org.apache.oro.text.regex.Pattern;
+import org.outerj.expression.Expression;
+
 /**
  * The {@link WidgetDefinition} part of a AggregateField widget, see {@link AggregateField}
  * for more information.
@@ -79,28 +82,28 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof AggregateFieldDefinition) {
-            AggregateFieldDefinition other = (AggregateFieldDefinition) definition;
+        if (!(definition instanceof AggregateFieldDefinition)) {
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not an AggregateFieldDefinition.",
+                                     getLocation());
+        }
+
+        AggregateFieldDefinition other = (AggregateFieldDefinition) definition;
+
+        this.combineExpr = other.combineExpr;
+        this.splitRegexp = other.splitRegexp;
+        this.splitPattern = other.splitPattern;
+        this.splitFailMessage = other.splitFailMessage;
+
+        Iterator defs = other.container.getWidgetDefinitions().iterator();
+        while (defs.hasNext()) {
+            container.addWidgetDefinition((WidgetDefinition) defs.next());
+        }
 
-            this.combineExpr = other.combineExpr;
-            this.splitRegexp = other.splitRegexp;
-            this.splitPattern = other.splitPattern;
-            this.splitFailMessage = other.splitFailMessage;
-
-            Iterator defs = other.container.getWidgetDefinitions().iterator();
-            while (defs.hasNext()) {
-                container.addWidgetDefinition((WidgetDefinition) defs.next());
-            }
-
-            Collections.copy(this.splitMappings, other.splitMappings);
-
-            Iterator fields = other.mappedFields.iterator();
-            while (fields.hasNext()) {
-                this.mappedFields.add(fields.next());
-            }
+        Collections.copy(this.splitMappings, other.splitMappings);
 
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
+        Iterator fields = other.mappedFields.iterator();
+        while (fields.hasNext()) {
+            this.mappedFields.add(fields.next());
         }
     }
 
@@ -178,7 +181,8 @@
         checkMutable();
 
         if (mappedFields.contains(fieldId)) {
-            throw new RuntimeException("Field '" + fieldId + "' is already mapped to another group!");
+            throw new FormsRuntimeException("Field '" + fieldId + "' is already mapped to another group.",
+                                            getLocation());
         }
 
         mappedFields.add(fieldId);

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -15,9 +15,12 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.excalibur.xml.sax.XMLizable;
+
 import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.util.DomHelper;
-import org.apache.excalibur.xml.sax.XMLizable;
+
 import org.apache.oro.text.regex.MalformedPatternException;
 import org.apache.oro.text.regex.Pattern;
 import org.apache.oro.text.regex.Perl5Compiler;
@@ -60,7 +63,8 @@
             try {
                 pattern = compiler.compile(patternString, Perl5Compiler.READ_ONLY_MASK);
             } catch (MalformedPatternException e) {
-                throw new Exception("Invalid regular expression at " + DomHelper.getLocation(splitElement) + ": " + e.getMessage());
+                throw new FormsException("Invalid regular expression '" + patternString + "'.",
+                                         e, DomHelper.getLocationObject(splitElement));
             }
             definition.setSplitPattern(pattern, patternString);
         }
@@ -72,15 +76,15 @@
             String field = DomHelper.getAttribute(mapElements[i], "field");
             // check that this field exists
             if (!definition.hasWidget(field)) {
-                throw new Exception("Unknown widget id \"" + field + "\", at " +
-                                    DomHelper.getLocation(mapElements[i]));
+                throw new FormsException("Unknown widget id '" + field + "' referenced.",
+                                         DomHelper.getLocationObject(mapElements[i]));
             }
 
             try {
                 definition.addSplitMapping(group, field);
             } catch(RuntimeException e) {
-                throw new Exception("Two groups are mapped to the same widget id \"" + field + "\", at " +
-                                    DomHelper.getLocation(mapElements[i]));
+                throw new FormsException("Two groups are mapped to the same widget id '" + field + "'.",
+                                         DomHelper.getLocationObject(mapElements[i]));
             }
         }
 
@@ -99,13 +103,13 @@
             try {
                 combineExpr = expressionManager.parse(combineExprString);
             } catch (Exception e) {
-                throw new Exception("Problem with combine expression defined at " +
-                                    DomHelper.getLocation(combineElement) + ": " + e.getMessage());
+                throw new FormsException("Invalid combine expression '" + combineExprString + "'.",
+                                         e, DomHelper.getLocationObject(combineElement));
             }
             Class clazz = definition.getDatatype().getTypeClass();
             if (combineExpr.getResultType() != null && !clazz.isAssignableFrom(combineExpr.getResultType())) {
-                throw new Exception("The result of the combine expression should be " + clazz.getName() + ", at " +
-                                    DomHelper.getLocation(combineElement));
+                throw new FormsException("The result of the combine expression should be '" + clazz.getName() + "', not '" + combineExpr.getResultType().getName() + "'.",
+                                         DomHelper.getLocationObject(combineElement));
             }
             definition.setCombineExpression(combineExpr);
         }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanField.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanField.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanField.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanField.java Tue Sep 19 19:48:01 2006
@@ -17,16 +17,22 @@
 
 import java.util.Locale;
 
-import org.apache.cocoon.forms.FormsConstants;
 import org.apache.cocoon.forms.FormContext;
-import org.apache.cocoon.forms.event.*;
+import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.FormsRuntimeException;
+import org.apache.cocoon.forms.event.ValueChangedEvent;
+import org.apache.cocoon.forms.event.ValueChangedListener;
+import org.apache.cocoon.forms.event.ValueChangedListenerEnabled;
+import org.apache.cocoon.forms.event.WidgetEvent;
+import org.apache.cocoon.forms.event.WidgetEventMulticaster;
+import org.apache.cocoon.forms.validation.ValidationError;
+import org.apache.cocoon.forms.validation.ValidationErrorAware;
 import org.apache.cocoon.xml.AttributesImpl;
 import org.apache.cocoon.xml.XMLUtils;
+
+import org.apache.commons.lang.BooleanUtils;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
-import org.apache.cocoon.forms.validation.ValidationErrorAware;
-import org.apache.cocoon.forms.validation.ValidationError;
-import org.apache.commons.lang.BooleanUtils;
 
 /**
  * A widget to select a boolean value. Usually rendered as a checkbox.
@@ -154,7 +160,7 @@
         }
 
         if (!(object instanceof Boolean)) {
-            throw new RuntimeException("Cannot set value of boolean field \"" + getRequestParameterName() + "\" to a non-Boolean value.");
+            throw new RuntimeException("Cannot set value of boolean field '" + getRequestParameterName() + "' to a non-Boolean value.");
         }
 
         Object oldValue = value;
@@ -180,7 +186,7 @@
     public void removeValueChangedListener(ValueChangedListener listener) {
         this.listener = WidgetEventMulticaster.remove(this.listener, listener);
     }
-    
+
     public boolean hasValueChangedListeners() {
         return this.listener != null;
     }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java Tue Sep 19 19:48:01 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.ValueChangedEvent;
 import org.apache.cocoon.forms.event.ValueChangedListener;
 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
@@ -41,16 +42,16 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof BooleanFieldDefinition) {
-            BooleanFieldDefinition other = (BooleanFieldDefinition) definition;
+        if (!(definition instanceof BooleanFieldDefinition)) {
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not a BooleanFieldDefinition.",
+                                     getLocation());
+        }
 
-            this.listener = other.listener;
-            this.initialValue = other.initialValue;
-            this.trueParamValue = other.trueParamValue;
+        BooleanFieldDefinition other = (BooleanFieldDefinition) definition;
 
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
-        }
+        this.listener = other.listener;
+        this.initialValue = other.initialValue;
+        this.trueParamValue = other.trueParamValue;
     }
 
     public void setInitialValue(Boolean value) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -15,9 +15,11 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
-import org.w3c.dom.Element;
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.util.DomHelper;
 
+import org.w3c.dom.Element;
+
 /**
  * The ButtonDefinitionBuilder has been replaced by {@link ActionDefinitionBuilder}. This implementation
  * is only left here to give a warning to users.
@@ -27,6 +29,7 @@
 public class ButtonDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
     public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
-        throw new Exception("The button widget has been renamed to action. Please update your form definition files. Found at " + DomHelper.getLocation(widgetElement));
+        throw new FormsException("The button widget has been renamed to action. Please update your form definition files.",
+                                 DomHelper.getLocationObject(widgetElement));
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java Tue Sep 19 19:48:01 2006
@@ -17,6 +17,8 @@
 
 import org.apache.avalon.framework.context.Context;
 
+import org.apache.cocoon.forms.FormsException;
+
 /**
  * A {@link FieldDefinition} for {@link CaptchaField}s.
  *
@@ -38,14 +40,14 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof CaptchaFieldDefinition) {
-            CaptchaFieldDefinition other = (CaptchaFieldDefinition) definition;
+        if (!(definition instanceof CaptchaFieldDefinition)) {
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not a CaptchaFieldDefinition.",
+                                     getLocation());
+        }
 
-            this.length = other.length;
+        CaptchaFieldDefinition other = (CaptchaFieldDefinition) definition;
 
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
-        }
+        this.length = other.length;
     }
 
     public Widget createInstance() {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -15,7 +15,9 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.util.DomHelper;
+
 import org.w3c.dom.Element;
 
 /**
@@ -29,9 +31,9 @@
         String id = DomHelper.getAttribute(element, "id");
 
         WidgetDefinition definition = context.getLocalLibrary().getDefinition(id);
-
         if (definition == null) {
-            throw new Exception("Widget '" + id + "' not found! (at " + DomHelper.getLocation(element) + ")");
+            throw new FormsException("Widget '" + id + "' not found.",
+                                     DomHelper.getLocationObject(element));
         }
 
         return definition;

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Field.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Field.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Field.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Field.java Tue Sep 19 19:48:01 2006
@@ -15,26 +15,32 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import java.util.Locale;
+
 import org.apache.cocoon.environment.Request;
-import org.apache.cocoon.forms.FormsConstants;
 import org.apache.cocoon.forms.FormContext;
+import org.apache.cocoon.forms.FormsConstants;
 import org.apache.cocoon.forms.FormsRuntimeException;
 import org.apache.cocoon.forms.datatype.Datatype;
 import org.apache.cocoon.forms.datatype.SelectionList;
 import org.apache.cocoon.forms.datatype.convertor.ConversionResult;
-import org.apache.cocoon.forms.event.*;
+import org.apache.cocoon.forms.event.DeferredValueChangedEvent;
+import org.apache.cocoon.forms.event.ValueChangedEvent;
+import org.apache.cocoon.forms.event.ValueChangedListener;
+import org.apache.cocoon.forms.event.ValueChangedListenerEnabled;
+import org.apache.cocoon.forms.event.WidgetEvent;
+import org.apache.cocoon.forms.event.WidgetEventMulticaster;
 import org.apache.cocoon.forms.util.I18nMessage;
 import org.apache.cocoon.forms.validation.ValidationError;
 import org.apache.cocoon.forms.validation.ValidationErrorAware;
 import org.apache.cocoon.xml.AttributesImpl;
 import org.apache.cocoon.xml.XMLUtils;
+
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.commons.lang.StringUtils;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
-import java.util.Locale;
-
 /**
  * A general-purpose Widget that can hold one value. A Field widget can be associated
  * with a {@link org.apache.cocoon.forms.datatype.Datatype Datatype}, and thus
@@ -172,9 +178,10 @@
      */
     public void setSuggestionLabel(String label) {
         if (this.fieldDefinition.getSuggestionList() == null) {
-            throw new FormsRuntimeException(this + " has no suggestion list", getLocation());
+            throw new FormsRuntimeException("Field '" + getRequestParameterName() + "' has no suggestion list.",
+                                            getLocation());
         }
-        this.setAttribute(SUGGESTED_LABEL_ATTR, label);
+        setAttribute(SUGGESTED_LABEL_ATTR, label);
     }
 
     /**
@@ -218,9 +225,9 @@
 
     public void setValue(Object newValue) {
         if (newValue != null && !getDatatype().getTypeClass().isAssignableFrom(newValue.getClass())) {
-            throw new RuntimeException("Incorrect value type for \"" + getRequestParameterName() +
-                           "\" (expected " + getDatatype().getTypeClass() +
-                           ", got " + newValue.getClass() + ").");
+            throw new FormsRuntimeException("Incorrect value type for '" + getRequestParameterName() +
+                                            "'. Expected " + getDatatype().getTypeClass() + ", got " + newValue.getClass() + ").",
+                                            getLocation());
         }
 
         // Is it a new value?

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java Tue Sep 19 19:48:01 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.datatype.SelectionList;
 
 /**
@@ -36,10 +37,12 @@
      * initialize this definition with the other, sort of like a copy constructor
      */
     public void initializeFrom(WidgetDefinition definition) throws Exception {
+        super.initializeFrom(definition);
+
         if (!(definition instanceof FieldDefinition)) {
-            throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not a FieldDefinition.",
+                                     getLocation());
         }
-        super.initializeFrom(definition);
 
         FieldDefinition other = (FieldDefinition)definition;
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FormDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FormDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FormDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FormDefinition.java Tue Sep 19 19:48:01 2006
@@ -18,11 +18,13 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.ProcessingPhaseEvent;
 import org.apache.cocoon.forms.event.ProcessingPhaseListener;
 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
 import org.apache.cocoon.forms.formmodel.library.Library;
 import org.apache.cocoon.forms.formmodel.library.LibraryManager;
+
 import org.apache.commons.lang.StringUtils;
 
 /**
@@ -79,8 +81,8 @@
         // Check that no child is named "submit" if this form has no id. This causes some weird behaviour
         // in HTML as it collides with the submit() function on the <form> element...
         if ("submit".equals(definition.getId()) && StringUtils.isEmpty(this.getId())) {
-            throw new IllegalArgumentException("Top-level widgets should not be named 'submit' to avoid problems " +
-                                               " with HTML <form> elements, at " + definition.getLocation());
+            throw new FormsException("Top-level widgets should not be named 'submit' to avoid problems " +
+                                     "with HTML <form> elements.", definition.getLocation());
         }
 
         super.addWidgetDefinition(definition);

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -15,10 +15,11 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.formmodel.library.Library;
 import org.apache.cocoon.forms.util.DomHelper;
-import org.w3c.dom.Element;
 
+import org.w3c.dom.Element;
 
 /**
  * @version $Id$
@@ -33,10 +34,9 @@
      */
     public WidgetDefinition buildWidgetDefinition(Element widgetElement)
     throws Exception {
-
         if (this.context == null || this.context.getLocalLibrary() == null) {
-            throw new Exception("Import statement seen and context is empty! (at " +
-                                DomHelper.getLocation(widgetElement) + ")");
+            throw new FormsException("Import statement seen and context is empty.",
+                                     DomHelper.getLocationObject(widgetElement));
         }
 
         Library lib = this.context.getLocalLibrary();
@@ -44,8 +44,8 @@
         String uri = DomHelper.getAttribute(widgetElement, URI_ATTRIBUTE);
 
         if (!lib.includeAs(prefix, uri)) {
-            throw new Exception("Import statement did not succeed (probably used ':' in the prefix?)! (at " +
-                                DomHelper.getLocation(widgetElement) + ")");
+            throw new FormsException("Import statement did not succeed (probably used ':' in the prefix?).",
+                                     DomHelper.getLocationObject(widgetElement));
         }
 
         return null;

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueField.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueField.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueField.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueField.java Tue Sep 19 19:48:01 2006
@@ -206,7 +206,7 @@
         } else if (value.getClass().isArray()) {
             setValues((Object[])value);
         } else {
-            throw new RuntimeException("Cannot set value of field \"" + getRequestParameterName() + "\" with an object of type " +
+            throw new RuntimeException("Cannot set value of field '" + getRequestParameterName() + "' with an object of type " +
                                        value.getClass().getName());
         }
         getForm().addWidgetUpdate(this);
@@ -216,7 +216,7 @@
         // check that all the objects in the array correspond to the datatype
         for (int i = 0; i < values.length; i++) {
             if (!definition.getDatatype().getTypeClass().isAssignableFrom(values[i].getClass())) {
-                throw new RuntimeException("Cannot set value of field \"" + getRequestParameterName() + "\" with an object of type " +
+                throw new RuntimeException("Cannot set value of field '" + getRequestParameterName() + "' with an object of type " +
                                            values[i].getClass().getName());
             }
         }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/NewDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/NewDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/NewDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/NewDefinition.java Tue Sep 19 19:48:01 2006
@@ -19,6 +19,8 @@
 import java.util.List;
 import java.util.ListIterator;
 
+import org.apache.cocoon.forms.FormsException;
+
 // TODO: The exception messages should use I18n.
 /**
  * This is the "{@link WidgetDefinition}" which is used to instantiate a
@@ -30,13 +32,10 @@
 public class NewDefinition extends AbstractWidgetDefinition {
 
     private boolean resolving;
-    private ClassDefinition classDefinition;
 
 
     public NewDefinition() {
         super();
-        resolving = false;
-        classDefinition = null;
     }
 
     private ClassDefinition getClassDefinition() throws Exception {
@@ -57,11 +56,13 @@
         }
 
         if (classDefinition == null) {
-            throw new Exception("NewDefinition: Class with id \"" + getId() + "\" does not exist (" + getLocation() + ")");
+            throw new FormsException("NewDefinition: Class with id '" + getId() + "' does not exist.",
+                                     getLocation());
         }
 
         if (!(classDefinition instanceof ClassDefinition)) {
-            throw new Exception("NewDefinition: Id \"" + getId() + "\" is not a class (" + getLocation() + ")");
+            throw new FormsException("NewDefinition: Id '" + getId() + "' is not a class.",
+                                     getLocation());
         }
 
         return (ClassDefinition) classDefinition;
@@ -80,8 +81,8 @@
                 }
 
                 if (definition == this) {
-                    throw new Exception("NewDefinition: Non-terminating recursion detected in widget definition : " +
-                                        parent.getId() + " (" + getLocation() + ")");
+                    throw new FormsException("NewDefinition: Non-terminating recursion detected in widget definition '" + parent.getId() + "'.",
+                                             getLocation());
                 }
             }
         }
@@ -89,24 +90,23 @@
         // Resolution
         resolving = true;
         parents.add(this);
-        classDefinition = getClassDefinition();
-        Iterator definitionsIt = classDefinition.getWidgetDefinitions().iterator();
+        Iterator definitionsIt = getClassDefinition().getWidgetDefinitions().iterator();
         parents.add(this);
         while (definitionsIt.hasNext()) {
-            WidgetDefinition definition = (WidgetDefinition)definitionsIt.next();
+            WidgetDefinition definition = (WidgetDefinition) definitionsIt.next();
             // Recursively resolve containers
             if (definition instanceof ContainerDefinition) {
-                ((ContainerDefinition)definition).resolve(parents, parent);
+                ((ContainerDefinition) definition).resolve(parents, parent);
             }
 
             // Add the current definition if it's not itself a "fd:new"
             if (definition instanceof NewDefinition) {
-                ((NewDefinition)definition).resolve(parents, parent);
+                ((NewDefinition) definition).resolve(parents, parent);
             } else {
-                ((ContainerDefinition)parent).addWidgetDefinition(definition);
+                ((ContainerDefinition) parent).addWidgetDefinition(definition);
             }
         }
-        parents.remove(parents.size()-1);
+        parents.remove(parents.size() - 1);
         resolving = false;
     }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Repeater.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Repeater.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Repeater.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Repeater.java Tue Sep 19 19:48:01 2006
@@ -349,8 +349,9 @@
     }
 
     public void readFromRequest(FormContext formContext) {
-        if (!getCombinedState().isAcceptingInputs())
+        if (!getCombinedState().isAcceptingInputs()) {
             return;
+        }
 
         // read number of rows from request, and make an according number of rows
         Request req = formContext.getRequest();
@@ -400,7 +401,8 @@
         // as reordering rows changes their IDs and therefore their child widget's ID too.
         if (action.equals("move")) {
             if (!this.orderable) {
-                throw new FormsRuntimeException(this + " is not orderable", getLocation());
+                throw new FormsRuntimeException("Widget " + this + " is not orderable",
+                                                getLocation());
             }
 
             int from = Integer.parseInt(req.getParameter(paramName + ".from"));
@@ -522,8 +524,8 @@
     public void generateWidgetLabel(String widgetId, ContentHandler contentHandler) throws SAXException {
         WidgetDefinition widgetDefinition = definition.getWidgetDefinition(widgetId);
         if (widgetDefinition == null) {
-            throw new SAXException("Repeater \"" + getRequestParameterName() + "\" at " + this.getLocation()
-                                   + " contains no widget with id \"" + widgetId + "\".");
+            throw new SAXException("Repeater '" + getRequestParameterName() + "' at " + getLocation()
+                                   + " contains no widget with id '" + widgetId + "'.");
         }
 
         widgetDefinition.generateLabel(contentHandler);
@@ -629,7 +631,7 @@
         }
 
         public void broadcastEvent(WidgetEvent event) {
-            throw new UnsupportedOperationException("Widget " + this.getRequestParameterName() + " doesn't handle events.");
+            throw new UnsupportedOperationException("Widget " + this + " doesn't handle events.");
         }
     }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java Tue Sep 19 19:48:01 2006
@@ -15,8 +15,7 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
-import org.apache.cocoon.forms.binding.BindingException;
-import org.apache.cocoon.forms.binding.RepeaterJXPathBinding;
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.ActionEvent;
 import org.apache.cocoon.forms.event.ActionListener;
 
@@ -51,14 +50,14 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof RepeaterActionDefinition) {
-            RepeaterActionDefinition other = (RepeaterActionDefinition) definition;
+        if (!(definition instanceof RepeaterActionDefinition)) {
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not a RepeaterActionDefinition.",
+                                     getLocation());
+        }
 
-            this.name = other.name;
+        RepeaterActionDefinition other = (RepeaterActionDefinition) definition;
 
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
-        }
+        this.name = other.name;
     }
 
     public Widget createInstance() {
@@ -99,14 +98,14 @@
         public void initializeFrom(WidgetDefinition definition) throws Exception {
             super.initializeFrom(definition);
 
-            if (definition instanceof DeleteRowsActionDefinition) {
-                DeleteRowsActionDefinition other = (DeleteRowsActionDefinition) definition;
+            if (!(definition instanceof DeleteRowsActionDefinition)) {
+                throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not a DeleteRowsActionDefinition.",
+                                         getLocation());
+            }
 
-                this.selectName = other.selectName;
+            DeleteRowsActionDefinition other = (DeleteRowsActionDefinition) definition;
 
-            } else {
-                throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
-            }
+            this.selectName = other.selectName;
         }
 
         public boolean hasActionListeners() {
@@ -168,14 +167,14 @@
         public void initializeFrom(WidgetDefinition definition) throws Exception {
             super.initializeFrom(definition);
 
-            if (definition instanceof InsertRowsActionDefinition) {
-                InsertRowsActionDefinition other = (InsertRowsActionDefinition) definition;
+            if (!(definition instanceof InsertRowsActionDefinition)) {
+                throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not an InsertRowsActionDefinition.",
+                                         getLocation());
+            }
 
-                this.selectName = other.selectName;
+            InsertRowsActionDefinition other = (InsertRowsActionDefinition) definition;
 
-            } else {
-                throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
-            }
+            this.selectName = other.selectName;
         }
 
         public InsertRowsActionDefinition(String repeaterName, String selectWidgetName) {
@@ -222,14 +221,15 @@
          */
         public void initializeFrom(WidgetDefinition definition) throws Exception {
             super.initializeFrom(definition);
-            if (definition instanceof ChangePageActionDefinition) {
-                ChangePageActionDefinition other = (ChangePageActionDefinition) definition;
-
-                this.method = other.method;
 
-            } else {
-                throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
+            if (!(definition instanceof ChangePageActionDefinition)) {
+                throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not a ChangePageActionDefinition.",
+                                         getLocation());
             }
+
+            ChangePageActionDefinition other = (ChangePageActionDefinition) definition;
+
+            this.method = other.method;
         }
 
         public ChangePageActionDefinition(String repeaterName, int m) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -18,9 +18,11 @@
 import java.util.Iterator;
 
 import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.ActionListener;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.apache.cocoon.util.Deprecation;
+
 import org.w3c.dom.Element;
 
 /**
@@ -65,8 +67,10 @@
                                         DomHelper.getLocation(widgetElement));
             }
         }
+
         if (actionCommand == null) {
-            throw new Exception("Missing attribute 'command' at " + DomHelper.getLocation(widgetElement));
+            throw new FormsException("Required attribute 'command' is missing.",
+                                     DomHelper.getLocationObject(widgetElement));
         }
 
 
@@ -79,13 +83,13 @@
         // Warn of the mis-named 'on-action' that existed initially
         Element buggyOnActivate = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "on-activate", false);
         if (buggyOnActivate != null) {
-            throw new Exception("Use 'on-action' instead of 'on-activate' on row-action at " +
-                                DomHelper.getLocation(buggyOnActivate));
+            throw new FormsException("Use 'on-action' instead of 'on-activate' on row-action.",
+                                     DomHelper.getLocationObject(buggyOnActivate));
         }
 
-        Iterator iter = buildEventListeners(widgetElement, "on-action", ActionListener.class).iterator();
-        while (iter.hasNext()) {
-            definition.addActionListener((ActionListener)iter.next());
+        Iterator i = buildEventListeners(widgetElement, "on-action", ActionListener.class).iterator();
+        while (i.hasNext()) {
+            definition.addActionListener((ActionListener) i.next());
         }
 
         definition.makeImmutable();
@@ -123,7 +127,8 @@
             return new RepeaterActionDefinition.ChangePageActionDefinition(repeater, RepeaterActionDefinition.ChangePageActionDefinition.CUSTOM);
 
         } else {
-            throw new Exception("Unknown repeater action '" + actionCommand + "' at " + DomHelper.getLineLocation(element));
+            throw new FormsException("Unknown repeater action '" + actionCommand + "'.",
+                                     DomHelper.getLocationObject(element));
         }
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java Tue Sep 19 19:48:01 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.RepeaterEvent;
 import org.apache.cocoon.forms.event.RepeaterListener;
 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
@@ -65,16 +66,16 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof RepeaterDefinition) {
-            RepeaterDefinition other = (RepeaterDefinition) definition;
+        if (!(definition instanceof RepeaterDefinition)) {
+            throw new FormsException("Parent definition " + definition.getClass().getName() + " is not a RepeaterDefinition.",
+                                     getLocation());
+        }
 
-            this.initialSize = other.initialSize;
-            this.maxSize = other.maxSize;
-            this.minSize = other.minSize;
+        RepeaterDefinition other = (RepeaterDefinition) definition;
 
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
-        }
+        this.initialSize = other.initialSize;
+        this.maxSize = other.maxSize;
+        this.minSize = other.minSize;
     }
 
     public Widget createInstance() {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -17,10 +17,11 @@
 
 import java.util.Iterator;
 
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.RepeaterListener;
 import org.apache.cocoon.forms.util.DomHelper;
+
 import org.w3c.dom.Element;
 
 /**
@@ -38,15 +39,18 @@
 
         // should throw error on negative values ? Just correct them for now.
         if (minSize < 0) {
-            throw new ConfigurationException("min-size should be positive, at " + DomHelper.getLocationObject(repeaterElement));
+            throw new FormsException("min-size should be positive.",
+                                     DomHelper.getLocationObject(repeaterElement));
         }
 
         if (maxSize < 0) {
-            throw new ConfigurationException("max-size should be positive, at " + DomHelper.getLocationObject(repeaterElement));
+            throw new FormsException("max-size should be positive.",
+                                     DomHelper.getLocationObject(repeaterElement));
         }
 
         if (maxSize < minSize) {
-            throw new ConfigurationException("max-size should be greater that or equal to min-size, at " + DomHelper.getLocationObject(repeaterElement));
+            throw new FormsException("max-size should be greater than or equal to min-size.",
+                                     DomHelper.getLocationObject(repeaterElement));
         }
 
         // initial size is at least the min size

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java Tue Sep 19 19:48:01 2006
@@ -18,6 +18,7 @@
 import java.util.Iterator;
 
 import org.apache.cocoon.forms.FormsConstants;
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.ActionListener;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.apache.cocoon.util.Deprecation;
@@ -43,7 +44,8 @@
             }
         }
         if (actionCommand == null) {
-            throw new Exception("Missing attribute 'command' at " + DomHelper.getLocation(widgetElement));
+            throw new FormsException("Required attribute 'command' is missing.",
+                                     DomHelper.getLocationObject(widgetElement));
         }
 
         RowActionDefinition definition = createDefinition(widgetElement, actionCommand);
@@ -55,8 +57,8 @@
         // Warn of the mis-named 'on-action' that existed initially
         Element buggyOnActivate = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "on-activate", false);
         if (buggyOnActivate != null) {
-            throw new Exception("Use 'on-action' instead of 'on-activate' on row-action at " +
-                                DomHelper.getLocation(buggyOnActivate));
+            throw new FormsException("Use 'on-action' instead of 'on-activate' on row-action.",
+                                     DomHelper.getLocationObject(buggyOnActivate));
         }
 
         Iterator iter = buildEventListeners(widgetElement, "on-action", ActionListener.class).iterator();
@@ -83,7 +85,8 @@
             return new RowActionDefinition.MoveDownDefinition();
 
         } else {
-            throw new Exception("Unknown repeater row action '" + actionCommand + "' at " + DomHelper.getLineLocation(element));
+            throw new FormsException("Unknown repeater row action '" + actionCommand + "'.",
+                                     DomHelper.getLocationObject(element));
         }
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java Tue Sep 19 19:48:01 2006
@@ -15,6 +15,8 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.forms.FormsException;
+
 /**
  * Definition for a {@link Submit}.
  *
@@ -31,14 +33,14 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof SubmitDefinition) {
-            SubmitDefinition other = (SubmitDefinition) definition;
+        if (!(definition instanceof SubmitDefinition)) {
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not a SubmitDefinition.",
+                                     getLocation());
+        }
 
-            this.validateForm = other.validateForm;
+        SubmitDefinition other = (SubmitDefinition) definition;
 
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
-        }
+        this.validateForm = other.validateForm;
     }
 
     public void setValidateForm(boolean validateForm) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java Tue Sep 19 19:48:01 2006
@@ -16,9 +16,11 @@
 package org.apache.cocoon.forms.formmodel;
 
 import org.apache.cocoon.forms.FormContext;
+import org.apache.cocoon.forms.FormsRuntimeException;
 import org.apache.cocoon.forms.event.ValueChangedEvent;
 import org.apache.cocoon.forms.event.ValueChangedListener;
 import org.apache.cocoon.forms.event.ValueChangedListenerEnabled;
+
 import org.apache.commons.lang.ObjectUtils;
 
 /**
@@ -61,8 +63,8 @@
         String caseWidgetId = definition.getCaseWidgetId();
         this.caseWidget = getParent().lookupWidget(caseWidgetId);
         if (this.caseWidget == null) {
-            throw new RuntimeException("Could not find case widget \"" + caseWidgetId +
-                                       "\" for union \"" + getId() + "\" at " + getLocation());
+            throw new FormsRuntimeException("Could not find case widget '" + caseWidgetId + "' for union '" + getId() + "'.",
+                                            getLocation());
         }
 
         ((ValueChangedListenerEnabled)caseWidget).addValueChangedListener(

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java Tue Sep 19 19:48:01 2006
@@ -15,6 +15,8 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.forms.FormsException;
+
 /**
  * The {@link WidgetDefinition} corresponding to a {@link Union} widget.
  *
@@ -31,14 +33,14 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof UnionDefinition) {
-            UnionDefinition other = (UnionDefinition) definition;
+        if (!(definition instanceof UnionDefinition)) {
+            throw new FormsException("Parent definition " + definition.getClass().getName() + " is not a UnionDefinition.",
+                                     getLocation());
+        }
 
-            this.caseWidgetId = other.caseWidgetId;
+        UnionDefinition other = (UnionDefinition) definition;
 
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ").");
-        }
+        this.caseWidgetId = other.caseWidgetId;
     }
 
     public void setCaseWidgetId(String id) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java Tue Sep 19 19:48:01 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.event.ValueChangedListener;
 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
 
@@ -44,16 +45,16 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if (definition instanceof UploadDefinition) {
-            UploadDefinition other = (UploadDefinition) definition;
+        if (!(definition instanceof UploadDefinition)) {
+            throw new FormsException("Ancestor definition " + definition.getClass().getName() + " is not an UploadDefinition.",
+                                     getLocation());
+        }
 
-            this.required = other.required;
-            this.mimeTypes = other.mimeTypes;
-            this.listener = WidgetEventMulticaster.add(this.listener, other.listener);
+        UploadDefinition other = (UploadDefinition) definition;
 
-        } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
-        }
+        this.required = other.required;
+        this.mimeTypes = other.mimeTypes;
+        this.listener = WidgetEventMulticaster.add(this.listener, other.listener);
     }
 
     public void addMimeTypes(String types) {
@@ -74,8 +75,7 @@
     }
 
     public Widget createInstance() {
-        Upload upload = new Upload(this);
-        return upload;
+        return new Upload(this);
     }
 
     public boolean isRequired() {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java?view=diff&rev=448035&r1=448034&r2=448035
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java Tue Sep 19 19:48:01 2006
@@ -22,6 +22,8 @@
 import java.util.ListIterator;
 import java.util.Map;
 
+import org.apache.cocoon.forms.FormsException;
+import org.apache.cocoon.forms.FormsRuntimeException;
 import org.apache.cocoon.util.location.Location;
 
 // TODO: Refine and i18n the exception messages.
@@ -118,11 +120,12 @@
                 if (widgetDefinition == containerDefinition) {
                     Location location = containerDefinition.getLocation();
                     if (parent instanceof FormDefinition) {
-                        throw new Exception("Container: Non-terminating recursion detected in form definition (" + location + ")");
+                        throw new FormsException("Container: Non-terminating recursion detected in form definition.",
+                                                 location);
                     }
 
-                    throw new Exception("Container: Non-terminating recursion detected in widget definition: " +
-                                        parent.getId() + " (" + location + ")");
+                    throw new FormsException("Container: Non-terminating recursion detected in widget definition: " + parent.getId(),
+                                             location);
                 }
             }
         }
@@ -131,8 +134,8 @@
     public void createWidget(Widget parent, String id) {
         WidgetDefinition widgetDefinition = (WidgetDefinition) widgetDefinitionsById.get(id);
         if (widgetDefinition == null) {
-            throw new RuntimeException(containerDefinition.getId() + ": WidgetDefinition \"" + id +
-                                       "\" does not exist (" + containerDefinition.getLocation() + ")");
+            throw new FormsRuntimeException(containerDefinition.getId() + ": WidgetDefinition '" + id + "' does not exist.",
+                                            containerDefinition.getLocation());
         }
 
         Widget widget = widgetDefinition.createInstance();



Mime
View raw message