cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r615293 - in /cocoon/branches/BRANCH_2_1_X: ./ src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ src/blocks/forms/java/org/apache/cocoon/forms/formmodel/library/ src/blocks/forms/java/org/apache/cocoon/forms/formmodel/tree/builder/
Date Fri, 25 Jan 2008 18:12:46 GMT
Author: vgritsenko
Date: Fri Jan 25 10:12:43 2008
New Revision: 615293

URL: http://svn.apache.org/viewvc?rev=615293&view=rev
Log:
    <action dev="VG" type="fix">
      Forms Block: Fixed concurrency issue in form definition builders code. If you have custom
      widgets, please implement WidgetDefinitionBuilder.buildWidgetDefinition(Element, WidgetDefinitionBuilderContext)
      method. Do not use WidgetDefinitionBuilder.buildWidgetDefinition(Element) method, it is intended to be
      implemented only by the top level widget (Form). 
    </action>


Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CalculatedFieldDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CaptchaDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GoogleMapDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GroupDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImageMapDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MessagesDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/NewDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/OutputDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterFilterFieldDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/StructDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -28,45 +28,43 @@
 
 public abstract class AbstractContainerDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
-    protected void setupContainer(Element element, String widgetsElementName, AbstractContainerDefinition definition)
+    protected void setupContainer(Element element,
+                                  String widgetsElementName,
+                                  AbstractContainerDefinition containerDefinition,
+                                  WidgetDefinitionBuilderContext containerContext)
     throws Exception {
 
         Element widgetsElement = DomHelper.getChildElement(element, FormsConstants.DEFINITION_NS, widgetsElementName, false);
-
-        // if its not there, ignore it. Just means that there are no new widgets
+        // If its not there, ignore it. Just means that there are no new widgets
         if (widgetsElement == null) {
             return;
         }
 
         // All child elements of the widgets element are widgets
         Element[] widgetElements = DomHelper.getChildElements(widgetsElement, FormsConstants.DEFINITION_NS);
-        WidgetDefinitionBuilderContext oldContext = this.context;
 
         for (int i = 0; i < widgetElements.length; i++) {
             Element widgetElement = widgetElements[i];
 
-            this.context = new WidgetDefinitionBuilderContext(oldContext);
-            this.context.setSuperDefinition(null);
+            WidgetDefinitionBuilderContext context = new WidgetDefinitionBuilderContext(containerContext);
+            context.setSuperDefinition(null);
 
             String newId = DomHelper.getAttribute(widgetElement, "extends", null);
             WidgetDefinition def;
             if (newId != null) {
-                if ((def = this.context.getLocalLibrary().getDefinition(newId)) != null) {
-                    this.context.setSuperDefinition(def);
-                } else if ((def = definition.getWidgetDefinition(newId)) != null) {
-                    this.context.setSuperDefinition(def);
+                if ((def = context.getLocalLibrary().getDefinition(newId)) != null) {
+                    context.setSuperDefinition(def);
+                } else if ((def = containerDefinition.getWidgetDefinition(newId)) != null) {
+                    context.setSuperDefinition(def);
                 }
-                // throw new FormsException("Widget to inherit from ("+newId+") not
-                // found!", DomHelper.getLocationObject(element));
+                // throw new FormsException("Widget to inherit from (" + newId + ") not found!",
+                //                          DomHelper.getLocationObject(element));
             }
 
-            WidgetDefinition widgetDefinition = buildAnotherWidgetDefinition(widgetElement);
-            if (widgetDefinition != null) {
-                definition.addWidgetDefinition(widgetDefinition);
+            WidgetDefinition definition = buildAnotherWidgetDefinition(widgetElement, context);
+            if (definition != null) {
+                containerDefinition.addWidgetDefinition(definition);
             }
-
         }
-
-        this.context = oldContext;
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -41,16 +41,18 @@
 public abstract class AbstractDatatypeWidgetDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
     protected void setupDefinition(Element widgetElement,
-                                   AbstractDatatypeWidgetDefinition definition)
+                                   AbstractDatatypeWidgetDefinition definition,
+                                   WidgetDefinitionBuilderContext context)
     throws Exception {
-        setupDefinition(widgetElement, definition, false);
+        setupDefinition(widgetElement, definition, context, false);
     }
 
     protected void setupDefinition(Element widgetElement,
                                    AbstractDatatypeWidgetDefinition definition,
+                                   WidgetDefinitionBuilderContext context,
                                    boolean isArrayType)
     throws Exception {
-        super.setupDefinition(widgetElement, definition);
+        super.setupDefinition(widgetElement, definition, context);
         // parse "label", "hint", etc.
         setDisplayData(widgetElement, definition);
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -59,8 +59,6 @@
     protected ExpressionManager expressionManager;
     protected ServiceManager serviceManager;
 
-    protected WidgetDefinitionBuilderContext context;
-
 
     public void service(ServiceManager serviceManager) throws ServiceException {
         this.serviceManager = serviceManager;
@@ -83,31 +81,17 @@
         this.serviceManager = null;
     }
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
-    throws Exception {
-        // so changes don't pollute upper levels
-        this.context = new WidgetDefinitionBuilderContext(context);
-
-        WidgetDefinition def = buildWidgetDefinition(widgetElement);
-
-        // register this class with the local library, if any.
-        if (DomHelper.getAttributeAsBoolean(widgetElement, "register", false) &&
-                this.context != null &&
-                this.context.getLocalLibrary() != null) {
-            this.context.getLocalLibrary().addDefinition(def);
-        }
-
-        this.context = null;
-        return def;
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+        throw new UnsupportedOperationException("Please use the other signature with WidgetDefinitionBuilderContext!");
     }
 
-    protected void setupDefinition(Element widgetElement, AbstractWidgetDefinition definition)
+    protected void setupDefinition(Element widgetElement, AbstractWidgetDefinition definition, WidgetDefinitionBuilderContext context)
     throws Exception {
         // location
         definition.setLocation(DomHelper.getLocationObject(widgetElement));
 
-        if (this.context.getSuperDefinition() != null) {
-            definition.initializeFrom(this.context.getSuperDefinition());
+        if (context.getSuperDefinition() != null) {
+            definition.initializeFrom(context.getSuperDefinition());
         }
 
         setCommonProperties(widgetElement, definition);
@@ -164,18 +148,25 @@
         }
     }
 
-    protected WidgetDefinition buildAnotherWidgetDefinition(Element widgetDefinition)
+    protected WidgetDefinition buildAnotherWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
     throws Exception {
-        String widgetName = widgetDefinition.getLocalName();
+        String widgetName = widgetElement.getLocalName();
         WidgetDefinitionBuilder builder;
         try {
-            builder = (WidgetDefinitionBuilder)widgetDefinitionBuilderSelector.select(widgetName);
+            builder = (WidgetDefinitionBuilder) widgetDefinitionBuilderSelector.select(widgetName);
         } catch (ServiceException e) {
             throw new FormsException("Unknown kind of widget '" + widgetName + "'.",
-                                     e, DomHelper.getLocationObject(widgetDefinition));
+                                     e, DomHelper.getLocationObject(widgetElement));
+        }
+
+        WidgetDefinition def = builder.buildWidgetDefinition(widgetElement, context);
+
+        // register this class with the local library, if any.
+        if (DomHelper.getAttributeAsBoolean(widgetElement, "register", false)) {
+            context.getLocalLibrary().addDefinition(def);
         }
 
-        return builder.buildWidgetDefinition(widgetDefinition, this.context);
+        return def;
     }
 
     protected List buildEventListeners(Element widgetElement, String elementName, Class listenerClass)

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -30,15 +30,18 @@
  */
 public class ActionDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         ActionDefinition definition = new ActionDefinition();
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
+
         definition.makeImmutable();
         return definition;
     }
 
-    protected void setupDefinition(Element widgetElement, ActionDefinition definition) throws Exception {
-        super.setupDefinition(widgetElement, definition);
+    protected void setupDefinition(Element widgetElement, ActionDefinition definition, WidgetDefinitionBuilderContext context)
+    throws Exception {
+        super.setupDefinition(widgetElement, definition, context);
 
         setDisplayData(widgetElement, definition);
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -35,24 +35,26 @@
  */
 public class AggregateFieldDefinitionBuilder extends FieldDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         AggregateFieldDefinition definition = new AggregateFieldDefinition();
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
+
         definition.makeImmutable();
         return definition;
     }
 
-    protected void setupDefinition(Element widgetElement, AggregateFieldDefinition definition) throws Exception {
-
+    protected void setupDefinition(Element widgetElement, AggregateFieldDefinition definition, WidgetDefinitionBuilderContext context)
+    throws Exception {
         // parse the field definition
-        super.setupDefinition(widgetElement, definition);
+        super.setupDefinition(widgetElement, definition, context);
 
         // make children fields
         Element widgetsElement = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "widgets", true);
         Element[] fieldElements = DomHelper.getChildElements(widgetsElement, FormsConstants.DEFINITION_NS, "field");
         for (int i = 0; i < fieldElements.length; i++) {
-            FieldDefinition fieldDefinition = (FieldDefinition)buildAnotherWidgetDefinition(fieldElements[i]);
-            definition.addWidgetDefinition(fieldDefinition);
+            FieldDefinition fd = (FieldDefinition) buildAnotherWidgetDefinition(fieldElements[i], context);
+            definition.addWidgetDefinition(fd);
         }
 
         // compile splitpattern

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -29,15 +29,16 @@
  * @version $Id$
  */
 public final class BooleanFieldDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
-        
+
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         BooleanFieldDefinition definition = new BooleanFieldDefinition();
-        
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
         setDisplayData(widgetElement, definition);
-        Iterator iter = buildEventListeners(widgetElement, "on-value-changed", ValueChangedListener.class).iterator();
-        while (iter.hasNext()) {
-            definition.addValueChangedListener((ValueChangedListener)iter.next());
+
+        Iterator i = buildEventListeners(widgetElement, "on-value-changed", ValueChangedListener.class).iterator();
+        while (i.hasNext()) {
+            definition.addValueChangedListener((ValueChangedListener) i.next());
         }
 
         // Initial value

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -29,7 +29,8 @@
  */
 public class ButtonDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         throw new FormsException("The button widget has been renamed to action. Please update your form definition files.",
                                  DomHelper.getLocationObject(widgetElement));
     }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CalculatedFieldDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CalculatedFieldDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CalculatedFieldDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CalculatedFieldDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -46,15 +46,18 @@
  */
 public class CalculatedFieldDefinitionBuilder extends FieldDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         CalculatedFieldDefinition definition = new CalculatedFieldDefinition();
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
+
         definition.makeImmutable();
         return definition;
     }
 
-    protected void setupDefinition(Element widgetElement, CalculatedFieldDefinition definition) throws Exception {
-        super.setupDefinition(widgetElement, definition);
+    protected void setupDefinition(Element widgetElement, CalculatedFieldDefinition definition, WidgetDefinitionBuilderContext context)
+    throws Exception {
+        super.setupDefinition(widgetElement, definition, context);
 
         Element algorithmElement = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "value");
         ServiceSelector builderSelector = (ServiceSelector)this.serviceManager.lookup(CalculatedFieldAlgorithmBuilder.ROLE + "Selector");

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CaptchaDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CaptchaDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CaptchaDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/CaptchaDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -37,15 +37,18 @@
         this.avalonContext = context;
     }
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         FieldDefinition definition = new CaptchaFieldDefinition(avalonContext);
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
+
         definition.makeImmutable();
         return definition;
     }
 
-    protected void setupDefinition(Element widgetElement, FieldDefinition definition) throws Exception {
-        super.setupDefinition(widgetElement, definition);
+    protected void setupDefinition(Element widgetElement, FieldDefinition definition, WidgetDefinitionBuilderContext context)
+    throws Exception {
+        super.setupDefinition(widgetElement, definition, context);
         
         // parse "@required"
         boolean required = DomHelper.getAttributeAsBoolean(widgetElement, "required", false);

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -25,16 +25,15 @@
  */
 public final class ClassDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element element, WidgetDefinitionBuilderContext context)
+    throws Exception {
         ClassDefinition definition = new ClassDefinition();
-        
-        super.setupDefinition(element, definition);
-        setDisplayData(element, definition);
+        setupDefinition(element, definition, context);
 
-        setupContainer(element,"widgets",definition);
+        setDisplayData(element, definition);
+        setupContainer(element, "widgets", definition, context);
 
         definition.makeImmutable();
-        
         return definition;
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -28,7 +28,8 @@
  */
 public class ExpandDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element element, WidgetDefinitionBuilderContext context)
+    throws Exception {
         String id = DomHelper.getAttribute(element, "id");
 
         WidgetDefinition definition = context.getLocalLibrary().getDefinition(id);

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -28,15 +28,18 @@
  */
 public class FieldDefinitionBuilder extends AbstractDatatypeWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         FieldDefinition definition = new FieldDefinition();
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
+
         definition.makeImmutable();
         return definition;
     }
 
-    protected void setupDefinition(Element widgetElement, FieldDefinition definition) throws Exception {
-        super.setupDefinition(widgetElement, definition);
+    protected void setupDefinition(Element widgetElement, FieldDefinition definition, WidgetDefinitionBuilderContext context)
+    throws Exception {
+        super.setupDefinition(widgetElement, definition, context);
 
         // parse "@required"
         if (widgetElement.hasAttribute("required")) {

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -46,8 +46,7 @@
 
     public WidgetDefinition buildWidgetDefinition(Element formElement) throws Exception {
         FormDefinition formDefinition = new FormDefinition(libraryManager);
-        this.context = new WidgetDefinitionBuilderContext();
-        this.context.setLocalLibrary(formDefinition.getLocalLibrary());
+        WidgetDefinitionBuilderContext context = new WidgetDefinitionBuilderContext(formDefinition.getLocalLibrary());
 
         // set local URI
         formDefinition.getLocalLibrary().setSourceURI(LocationAttributes.getURI(formElement));
@@ -57,16 +56,12 @@
             formDefinition.addProcessingPhaseListener((ProcessingPhaseListener) i.next());
         }
 
-        super.setupDefinition(formElement, formDefinition);
+        setupDefinition(formElement, formDefinition, context);
         setDisplayData(formElement, formDefinition);
-
-        setupContainer(formElement,"widgets",formDefinition);
+        setupContainer(formElement, "widgets", formDefinition, context);
 
         formDefinition.resolve();
-
         formDefinition.makeImmutable();
-
-        this.context = null;
         return formDefinition;
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GoogleMapDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GoogleMapDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GoogleMapDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GoogleMapDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -27,11 +27,11 @@
  * Builds {@link GoogleMapDefinition}s.
  */
 public final class GoogleMapDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
-        
+
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         GoogleMapDefinition definition = new GoogleMapDefinition();
-        
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
         setDisplayData(widgetElement, definition);
 
         // Initial value

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GroupDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GroupDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GroupDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/GroupDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -25,14 +25,14 @@
  */
 public final class GroupDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element element, WidgetDefinitionBuilderContext context)
+    throws Exception {
         GroupDefinition definition = new GroupDefinition();
-        
-        super.setupDefinition(element, definition);
+        setupDefinition(element, definition, context);
+
         setDisplayData(element, definition);
+        setupContainer(element, "widgets", definition, context);
 
-        setupContainer(element,"widgets",definition);
-        
         definition.makeImmutable();
         return definition;
     }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImageMapDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImageMapDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImageMapDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImageMapDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -31,15 +31,18 @@
  */
 public class ImageMapDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         ImageMapDefinition definition = new ImageMapDefinition();
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
+
         definition.makeImmutable();
         return definition;
     }
 
-    protected void setupDefinition(Element widgetElement, ImageMapDefinition definition) throws Exception {
-        super.setupDefinition(widgetElement, definition);
+    protected void setupDefinition(Element widgetElement, ImageMapDefinition definition, WidgetDefinitionBuilderContext context)
+    throws Exception {
+        super.setupDefinition(widgetElement, definition, context);
 
         setDisplayData(widgetElement, definition);
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -33,14 +33,14 @@
     /**
      * Imports a new library
      */
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement)
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
     throws Exception {
-        if (this.context == null || this.context.getLocalLibrary() == null) {
+        if (context.getLocalLibrary() == null) {
             throw new FormsException("Import statement seen and context is empty.",
                                      DomHelper.getLocationObject(widgetElement));
         }
 
-        Library lib = this.context.getLocalLibrary();
+        Library lib = context.getLocalLibrary();
         String prefix = DomHelper.getAttribute(widgetElement, PREFIX_ATTRIBUTE);
         String uri = DomHelper.getAttribute(widgetElement, URI_ATTRIBUTE);
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MessagesDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MessagesDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MessagesDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MessagesDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -24,11 +24,14 @@
  * @version $Id$
  */
 public final class MessagesDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
-        MessagesDefinition messagesDefinition = new MessagesDefinition();
-        super.setupDefinition(widgetElement, messagesDefinition);
-        setDisplayData(widgetElement, messagesDefinition);
-        messagesDefinition.makeImmutable();
-        return messagesDefinition;
+
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
+        MessagesDefinition definition = new MessagesDefinition();
+        setupDefinition(widgetElement, definition, context);
+        setDisplayData(widgetElement, definition);
+
+        definition.makeImmutable();
+        return definition;
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -25,9 +25,11 @@
  */
 public class MultiValueFieldDefinitionBuilder extends AbstractDatatypeWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         MultiValueFieldDefinition definition = new MultiValueFieldDefinition();
-        setupDefinition(widgetElement, definition, true);
+        setupDefinition(widgetElement, definition, context, true);
+
         definition.makeImmutable();
         return definition;
     }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/NewDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/NewDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/NewDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/NewDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -25,9 +25,10 @@
  */
 public class NewDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element element, WidgetDefinitionBuilderContext context) throws Exception {
         NewDefinition definition = new NewDefinition();
-        super.setupDefinition(element, definition);
+        setupDefinition(element, definition, context);
+
         definition.makeImmutable();
         return definition;
     }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/OutputDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/OutputDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/OutputDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/OutputDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -26,9 +26,11 @@
  */
 public class OutputDefinitionBuilder extends AbstractDatatypeWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         OutputDefinition definition = new OutputDefinition();
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
+
         definition.makeImmutable();
         return definition;
     }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -56,7 +56,8 @@
  */
 public class RepeaterActionDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         // Get the "command" attribute
         String actionCommand = DomHelper.getAttribute(widgetElement, "command", null);
 
@@ -76,7 +77,7 @@
 
 
         RepeaterActionDefinition definition = createDefinition(widgetElement, actionCommand);
-        super.setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
         setDisplayData(widgetElement, definition);
 
         definition.setActionCommand(actionCommand);

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -32,7 +32,8 @@
  */
 public final class RepeaterDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element repeaterElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element repeaterElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
 
         int initialSize = DomHelper.getAttributeAsInteger(repeaterElement, "initial-size", 0);
         int minSize = DomHelper.getAttributeAsInteger(repeaterElement, "min-size", 0);
@@ -74,16 +75,16 @@
         }
 
         RepeaterDefinition repeaterDefinition = new RepeaterDefinition(initialSize, minSize, maxSize, selectable, orderable, enhanced, initialPage, pageSize, customPageId);
-        super.setupDefinition(repeaterElement, repeaterDefinition);
+        setupDefinition(repeaterElement, repeaterDefinition, context);
         setDisplayData(repeaterElement, repeaterDefinition);
 
         // parse "on-repeater-modified"
-        Iterator iter = buildEventListeners(repeaterElement, "on-repeater-modified", RepeaterListener.class).iterator();
-        while (iter.hasNext()) {
-            repeaterDefinition.addRepeaterListener((RepeaterListener)iter.next());
+        Iterator i = buildEventListeners(repeaterElement, "on-repeater-modified", RepeaterListener.class).iterator();
+        while (i.hasNext()) {
+            repeaterDefinition.addRepeaterListener((RepeaterListener) i.next());
         }
 
-        setupContainer(repeaterElement,"widgets",repeaterDefinition);
+        setupContainer(repeaterElement, "widgets", repeaterDefinition, context);
 
         repeaterDefinition.makeImmutable();
         return repeaterDefinition;

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterFilterFieldDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterFilterFieldDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterFilterFieldDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RepeaterFilterFieldDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -19,20 +19,25 @@
 import org.apache.cocoon.forms.util.DomHelper;
 import org.w3c.dom.Element;
 
-public class RepeaterFilterFieldDefinitionBuilder extends
-		FieldDefinitionBuilder {
+/**
+ * @version $Id$
+ */
+public class RepeaterFilterFieldDefinitionBuilder extends FieldDefinitionBuilder {
 
-	public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+	public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         RepeaterFilterFieldDefinition definition = new RepeaterFilterFieldDefinition();
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
+
         definition.makeImmutable();
         return definition;
 	}
 
-	protected void setupDefinition(Element widgetElement,RepeaterFilterFieldDefinition definition) throws Exception {
-		super.setupDefinition(widgetElement, definition);
-		definition.setRepeaterName(DomHelper.getAttribute(widgetElement, "repeater"));
+	protected void setupDefinition(Element widgetElement,RepeaterFilterFieldDefinition definition, WidgetDefinitionBuilderContext context)
+    throws Exception {
+		super.setupDefinition(widgetElement, definition, context);
+
+        definition.setRepeaterName(DomHelper.getAttribute(widgetElement, "repeater"));
 		definition.setField(DomHelper.getAttribute(widgetElement, "field"));
 	}
-
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -32,7 +32,8 @@
 public class RowActionDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         // Get the "command" attribute
         String actionCommand = DomHelper.getAttribute(widgetElement, "command", null);
 
@@ -50,7 +51,7 @@
         }
 
         RowActionDefinition definition = createDefinition(widgetElement, actionCommand);
-        super.setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
         setDisplayData(widgetElement, definition);
 
         definition.setActionCommand(actionCommand);
@@ -62,9 +63,9 @@
                                      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();
@@ -72,7 +73,6 @@
     }
 
     protected RowActionDefinition createDefinition(Element element, String actionCommand) throws Exception {
-
         if ("delete".equals(actionCommand)) {
             return new RowActionDefinition.DeleteRowDefinition();
 
@@ -91,4 +91,3 @@
         }
     }
 }
-

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/StructDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/StructDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/StructDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/StructDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -27,12 +27,13 @@
  */
 public class StructDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element element, WidgetDefinitionBuilderContext context)
+    throws Exception {
         StructDefinition definition = new StructDefinition();
-        super.setupDefinition(element, definition);
-        setDisplayData(element, definition);
+        setupDefinition(element, definition, context);
 
-        setupContainer(element,"widgets",definition);
+        setDisplayData(element, definition);
+        setupContainer(element, "widgets", definition, context);
 
         definition.makeImmutable();
         Deprecation.logger.info("Use of 'fd:struct' is deprecated. Use 'fd:group' instead, at " + definition.getLocation());

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -38,9 +38,10 @@
  */
 public final class SubmitDefinitionBuilder extends ActionDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         SubmitDefinition definition = new SubmitDefinition();
-        super.setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
 
         // parse "@validate"
         if (widgetElement.hasAttribute("validate")) {
@@ -48,7 +49,6 @@
         }
 
         definition.makeImmutable();
-
         return definition;
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -26,17 +26,17 @@
  */
 public final class UnionDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element element, WidgetDefinitionBuilderContext context)
+    throws Exception {
         UnionDefinition definition = new UnionDefinition();
-        super.setupDefinition(element, definition);
+        setupDefinition(element, definition, context);
+
         definition.setCaseWidgetId(DomHelper.getAttribute(element, "case"));
         setDisplayData(element, definition);
-
-        setupContainer(element,"widgets",definition);
+        setupContainer(element, "widgets", definition, context);
 
         definition.makeImmutable();
         return definition;
     }
     // TODO: Need to add code somewhere to build a selection list for the case widget.
 }
-

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -29,22 +29,22 @@
  */
 public final class UploadDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
-        String mimeTypes = DomHelper.getAttribute(widgetElement, "mime-types", null);
-        
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         UploadDefinition uploadDefinition = new UploadDefinition();
-        super.setupDefinition(widgetElement, uploadDefinition);
+        setupDefinition(widgetElement, uploadDefinition, context);
 
         setDisplayData(widgetElement, uploadDefinition);
-        Iterator iter = buildEventListeners(widgetElement, "on-value-changed", ValueChangedListener.class).iterator();
-        while (iter.hasNext()) {
-            uploadDefinition.addValueChangedListener((ValueChangedListener)iter.next());
+        Iterator i = buildEventListeners(widgetElement, "on-value-changed", ValueChangedListener.class).iterator();
+        while (i.hasNext()) {
+            uploadDefinition.addValueChangedListener((ValueChangedListener)i.next());
         }
 
-        
-        if(widgetElement.hasAttribute("required"))
+        if (widgetElement.hasAttribute("required")) {
             uploadDefinition.setRequired(DomHelper.getAttributeAsBoolean(widgetElement, "required", false));
-        
+        }
+
+        String mimeTypes = DomHelper.getAttribute(widgetElement, "mime-types", null);
         uploadDefinition.addMimeTypes(mimeTypes);
 
         uploadDefinition.makeImmutable();

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java Fri Jan 25 10:12:43 2008
@@ -25,16 +25,25 @@
  */
 public class WidgetDefinitionBuilderContext {
 
-    protected WidgetDefinition superDefinition;
-    protected Library localLibrary;
+    private final Library library;
+    private WidgetDefinition superDefinition;
 
 
-    public WidgetDefinitionBuilderContext() {
+    public WidgetDefinitionBuilderContext(Library library) {
+        this.library = library;
     }
 
+    /**
+     * Create context which inherits library from another context.
+     *
+     * @param other context to borrow library from
+     */
     public WidgetDefinitionBuilderContext(WidgetDefinitionBuilderContext other) {
-        this.superDefinition = other.superDefinition;
-        this.localLibrary = other.localLibrary;
+        this.library = other.library;
+    }
+
+    public Library getLocalLibrary() {
+        return library;
     }
 
     public WidgetDefinition getSuperDefinition() {
@@ -43,13 +52,5 @@
 
     public void setSuperDefinition(WidgetDefinition def) {
         superDefinition = def;
-    }
-
-    public Library getLocalLibrary() {
-        return localLibrary;
-    }
-
-    public void setLocalLibrary(Library lib) {
-        localLibrary = lib;
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java Fri Jan 25 10:12:43 2008
@@ -57,13 +57,10 @@
     protected final Object shared = new Object();
 
     protected String sourceURI;
-    protected WidgetDefinitionBuilderContext context;
 
 
     public Library(LibraryManager lm, ServiceSelector builderSelector) {
         manager = lm;
-        context = new WidgetDefinitionBuilderContext();
-        context.setLocalLibrary(this);
         widgetDefinitionBuilderSelector = builderSelector;
     }
 
@@ -138,13 +135,36 @@
     public void buildLibrary(Element libraryElement) throws Exception {
         sourceURI = LocationAttributes.getURI(libraryElement);
         Element widgetsElement = DomHelper.getChildElement(libraryElement, FormsConstants.DEFINITION_NS, "widgets", true);
+
+        WidgetDefinitionBuilderContext context = new WidgetDefinitionBuilderContext(this);
+
         // All child elements of the widgets element are widgets
         Element[] widgetElements = DomHelper.getChildElements(widgetsElement, FormsConstants.DEFINITION_NS);
         for (int i = 0; i < widgetElements.length; i++) {
             Element widgetElement = widgetElements[i];
-            WidgetDefinition widgetDefinition = buildWidgetDefinition(widgetElement);
-            addDefinition(widgetDefinition);
+            buildWidgetDefinition(widgetElement, context);
+        }
+    }
+
+    private void buildWidgetDefinition(Element widgetDefinition, WidgetDefinitionBuilderContext context)
+    throws Exception {
+        String widgetName = widgetDefinition.getLocalName();
+        WidgetDefinitionBuilder builder;
+        try {
+            builder = (WidgetDefinitionBuilder) widgetDefinitionBuilderSelector.select(widgetName);
+        } catch (ServiceException e) {
+            throw new LibraryException("Unknown kind of widget '" + widgetName + "'.",
+                                       e, DomHelper.getLocationObject(widgetDefinition));
+        }
+
+        context.setSuperDefinition(null);
+        String extend = DomHelper.getAttribute(widgetDefinition, "extends", null);
+        if (extend != null) {
+            context.setSuperDefinition(getDefinition(extend));
         }
+
+        WidgetDefinition definition = builder.buildWidgetDefinition(widgetDefinition, context);
+        addDefinition(definition);
     }
 
     public void addDefinition(WidgetDefinition definition) throws LibraryException {
@@ -166,27 +186,7 @@
         }
     }
 
-    protected WidgetDefinition buildWidgetDefinition(Element widgetDefinition) throws Exception {
-        String widgetName = widgetDefinition.getLocalName();
-        WidgetDefinitionBuilder builder;
-        try {
-            builder = (WidgetDefinitionBuilder) widgetDefinitionBuilderSelector.select(widgetName);
-        } catch (ServiceException e) {
-            throw new LibraryException("Unknown kind of widget '" + widgetName + "'.",
-                                       e, DomHelper.getLocationObject(widgetDefinition));
-        }
-
-        context.setSuperDefinition(null);
-
-        String extend = DomHelper.getAttribute(widgetDefinition, "extends", null);
-        if (extend != null) {
-            context.setSuperDefinition(getDefinition(extend));
-        }
-
-        return builder.buildWidgetDefinition(widgetDefinition,context);
-    }
-
-
+    
     /**
      * Encapsulates a uri to designate an import plus a timestamp so previously reloaded
      */
@@ -205,5 +205,4 @@
             return lib != null && this.shared == lib.shared;
         }
     }
-
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/tree/builder/TreeDefinitionBuilder.java Fri Jan 25 10:12:43 2008
@@ -24,6 +24,7 @@
 import org.apache.cocoon.forms.FormsException;
 import org.apache.cocoon.forms.formmodel.AbstractWidgetDefinitionBuilder;
 import org.apache.cocoon.forms.formmodel.WidgetDefinition;
+import org.apache.cocoon.forms.formmodel.WidgetDefinitionBuilderContext;
 import org.apache.cocoon.forms.formmodel.tree.Tree;
 import org.apache.cocoon.forms.formmodel.tree.TreeDefinition;
 import org.apache.cocoon.forms.formmodel.tree.TreeSelectionListener;
@@ -38,15 +39,18 @@
  */
 public class TreeDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context)
+    throws Exception {
         TreeDefinition definition = new TreeDefinition();
-        setupDefinition(widgetElement, definition);
+        setupDefinition(widgetElement, definition, context);
+
         definition.makeImmutable();
         return definition;
     }
 
-    protected void setupDefinition(Element widgetElement, TreeDefinition definition) throws Exception {
-        super.setupDefinition(widgetElement, definition);
+    protected void setupDefinition(Element widgetElement, TreeDefinition definition, WidgetDefinitionBuilderContext context)
+    throws Exception {
+        super.setupDefinition(widgetElement, definition, context);
 
         // Get the optional "root-visible" attribute
         definition.setRootVisible(DomHelper.getAttributeAsBoolean(widgetElement, "root-visible", true));
@@ -81,10 +85,11 @@
         }
 
         // parse "on-selection-changed"
-        Iterator iter = buildEventListeners(widgetElement, "on-selection-changed", TreeSelectionListener.class).iterator();
-        while (iter.hasNext()) {
-            definition.addSelectionListener((TreeSelectionListener)iter.next());
+        Iterator i = buildEventListeners(widgetElement, "on-selection-changed", TreeSelectionListener.class).iterator();
+        while (i.hasNext()) {
+            definition.addSelectionListener((TreeSelectionListener)i.next());
         }
+
         //TODO: allow child widgets, that will be attached to each node of the tree
         //It may be useful to add TreeModel.getNodeType(Object) so that the container holding child
         //widgets can have a value used by a union widget.

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=615293&r1=615292&r2=615293&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Fri Jan 25 10:12:43 2008
@@ -182,6 +182,12 @@
 
   <changes>
   <release version="2.1.12" date="TBD">
+    <action dev="VG" type="fix">
+      Forms Block: Fixed concurrency issue in form definition builders code. If you have custom
+      widgets, please implement WidgetDefinitionBuilder.buildWidgetDefinition(Element, WidgetDefinitionBuilderContext)
+      method. Do not use WidgetDefinitionBuilder.buildWidgetDefinition(Element) method, it is intended to be
+      implemented only by the top level widget (Form). 
+    </action>
     <action dev="JH" type="add" fixes-bug="COCOON-2149" due-to="Ellis Pritchard" due-to-email="ellis@nukinetics.com">
       Add capability to IncludeTransformer to strip the root element from included XML content.
     </action>



Mime
View raw message