You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by ti...@apache.org on 2004/09/09 20:40:17 UTC

svn commit: rev 43621 - cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel

Author: tim
Date: Thu Sep  9 11:40:15 2004
New Revision: 43621

Modified:
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerWidget.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Action.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueField.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Repeater.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Union.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Upload.java
   cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java
Log:
Allow to turn off request processing for widgets.
Move some private "static final String"'s.


Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerWidget.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerWidget.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerWidget.java	Thu Sep  9 11:40:15 2004
@@ -82,7 +82,9 @@
      *                    of the contained widgets.
      */
     public void readFromRequest(FormContext formContext) {
-        widgets.readFromRequest(formContext);
+        if(getProcessRequests() == true) {
+            widgets.readFromRequest(formContext);
+        }
     }
 
     /**

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java	Thu Sep  9 11:40:15 2004
@@ -43,7 +43,12 @@
      * property through own implemented getParent()
      */
     private Widget parent;
-    
+
+    /**
+     * Process request parameters for this widget?
+     */
+    private boolean processRequests = true;
+
     /**
      * Lazy loaded reference to the top-level form.
      */
@@ -197,6 +202,22 @@
 
     public void setValue(Object object) {
         throw new RuntimeException("Cannot set the value of widget " + getRequestParameterName());
+    }
+
+    /**
+     * Returns whether {@link #readFromRequest(FormContext formContext)}
+     * processes the request parameter(s) for this widget.
+     */
+    public boolean getProcessRequests() {
+      return this.processRequests;
+    }
+
+    /**
+     * Controls whether {@link #readFromRequest(FormContext formContext)}
+     * processes the request parameter(s) for this widget.
+     */
+    public void setProcessRequests(boolean processRequests) {
+      this.processRequests = processRequests;
     }
 
     public boolean isRequired() {

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Action.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Action.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Action.java	Thu Sep  9 11:40:15 2004
@@ -28,7 +28,7 @@
  * ActionEvent when a requestparameter is present with as name the id of this Action widget, and as
  * value a non-empty value.
  * 
- * @version $Id: Action.java,v 1.10 2004/05/07 13:42:09 mpo Exp $
+ * @version $Id$
  */
 public class Action extends AbstractWidget implements ActionListenerEnabled {
     private final ActionDefinition definition;
@@ -42,38 +42,40 @@
     protected WidgetDefinition getDefinition() {
         return this.definition;
     }
-    
+
     public void readFromRequest(final FormContext formContext) {
-        Form form = getForm();
-        
-        // Set the submit widget if we can determine it from the request
-        String fullId = getRequestParameterName();
-        Request request = formContext.getRequest();
-        
-        String value = request.getParameter(fullId);
-        if (value != null && value.length() > 0) {
-            form.setSubmitWidget(this);
-            
-        } else {
-            // Special workaround an IE bug for <input type="image" name="foo"> :
-            // in that case, IE only sends "foo.x" and "foo.y" and not "foo" whereas
-            // standards-compliant browsers such as Mozilla do send the "foo" parameter.
-            //
-            // Note that since actions are terminal widgets, there's no chance of conflict
-            // with a child "x" or "y" widget.
-            value = request.getParameter(fullId + ".x");
-            if ((value != null) && value.length() > 0) {
+        if(getProcessRequests() == true) {
+            Form form = getForm();
+
+            // Set the submit widget if we can determine it from the request
+            String fullId = getRequestParameterName();
+            Request request = formContext.getRequest();
+
+            String value = request.getParameter(fullId);
+            if (value != null && value.length() > 0) {
                 form.setSubmitWidget(this);
+
+            } else {
+                // Special workaround an IE bug for <input type="image" name="foo"> :
+                // in that case, IE only sends "foo.x" and "foo.y" and not "foo" whereas
+                // standards-compliant browsers such as Mozilla do send the "foo" parameter.
+                //
+                // Note that since actions are terminal widgets, there's no chance of conflict
+                // with a child "x" or "y" widget.
+                value = request.getParameter(fullId + ".x");
+                if ((value != null) && value.length() > 0) {
+                    form.setSubmitWidget(this);
+                }
+            }
+
+            if (form.getSubmitWidget() == this) {
+                form.addWidgetEvent(new ActionEvent(this, definition.getActionCommand()));
+
+                handleActivate();
             }
-        }
-        
-        if (form.getSubmitWidget() == this) {
-            form.addWidgetEvent(new ActionEvent(this, definition.getActionCommand()));
-            
-            handleActivate();
         }
     }
-    
+
     /**
      * Handle the fact that this action was activated. The default here is to end the
      * current form processing and redisplay the form, which means that actual behaviour

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java	Thu Sep  9 11:40:15 2004
@@ -49,7 +49,7 @@
  * gives result of the correct type, and split regular expression can split string representation
  * into parts which can be converted to the values of nested fields.
  *
- * @version CVS $Id: AggregateField.java,v 1.12 2004/07/11 17:19:54 vgritsenko Exp $
+ * @version CVS $Id$
  */
 public class AggregateField extends Field implements ContainerWidget {
 
@@ -95,24 +95,26 @@
     }
 
     public void readFromRequest(FormContext formContext) {
-        String newEnteredValue = formContext.getRequest().getParameter(getRequestParameterName());
-        if (newEnteredValue != null) {
-            // There is one aggregated entered value. Read it and split it.
-            super.readFromRequest(formContext);
-            if (this.valueState == VALUE_UNPARSED) {
-                setFieldsValues(enteredValue);
-            }
-        } else {
-            // Check if there are multiple splitted values. Read them and aggregate them.
-            for (Iterator i = fields.iterator(); i.hasNext();) {
-                Field field = (Field)i.next();
-                field.readFromRequest(formContext);
-                if (field.valueState == VALUE_UNPARSED) {
-                    this.valueState = VALUE_UNPARSED;
+        if(getProcessRequests() == true) {
+            String newEnteredValue = formContext.getRequest().getParameter(getRequestParameterName());
+            if (newEnteredValue != null) {
+                // There is one aggregated entered value. Read it and split it.
+                super.readFromRequest(formContext);
+                if (this.valueState == VALUE_UNPARSED) {
+                    setFieldsValues(enteredValue);
+                }
+            } else {
+                // Check if there are multiple splitted values. Read them and aggregate them.
+                for (Iterator i = fields.iterator(); i.hasNext();) {
+                    Field field = (Field)i.next();
+                    field.readFromRequest(formContext);
+                    if (field.valueState == VALUE_UNPARSED) {
+                        this.valueState = VALUE_UNPARSED;
+                    }
+                }
+                if (this.valueState == VALUE_UNPARSED) {
+                    combineFields();
                 }
-            }
-            if (this.valueState == VALUE_UNPARSED) {
-                combineFields();
             }
         }
     }

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java	Thu Sep  9 11:40:15 2004
@@ -39,9 +39,14 @@
  * and the manner in which the request parameter of this widget is interpreted
  * is different (missing or empty request parameter means 'false', rather than null value).
  * 
- * @version $Id: BooleanField.java,v 1.11 2004/07/02 09:17:08 jeremy Exp $
+ * @version $Id$
  */
 public class BooleanField extends AbstractWidget implements ValidationErrorAware, ValueChangedListenerEnabled {
+
+    private static final String BOOLEAN_FIELD_EL = "booleanfield";
+    private static final String VALUE_EL = "value";
+    private static final String VALIDATION_MSG_EL = "validation-message";
+
     // FIXME(SW) : should the initial value be false or null ? This would allow
     // event listeners to be triggered at bind time.
     private Boolean value = Boolean.FALSE;
@@ -59,16 +64,18 @@
     }
 
     public void readFromRequest(FormContext formContext) {
-        validationError = null;
-        Object oldValue = value;
-        String param = formContext.getRequest().getParameter(getRequestParameterName());
-        if (param != null && param.equalsIgnoreCase("true"))
-            value = Boolean.TRUE;
-        else
-            value = Boolean.FALSE;
-        
-        if (value != oldValue) {
-            getForm().addWidgetEvent(new ValueChangedEvent(this, oldValue, value));
+        if(getProcessRequests() == true) {
+            validationError = null;
+            Object oldValue = value;
+            String param = formContext.getRequest().getParameter(getRequestParameterName());
+            if (param != null && param.equalsIgnoreCase("true"))
+                value = Boolean.TRUE;
+            else
+                value = Boolean.FALSE;
+            
+            if (value != oldValue) {
+                getForm().addWidgetEvent(new ValueChangedEvent(this, oldValue, value));
+            }
         }
     }
 
@@ -102,11 +109,6 @@
         this.validationError = error;
     }
 
-
-    private static final String BOOLEAN_FIELD_EL = "booleanfield";
-    private static final String VALUE_EL = "value";
-    private static final String VALIDATION_MSG_EL = "validation-message";
-    
     /**
      * @return "booleanfield"
      */

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java	Thu Sep  9 11:40:15 2004
@@ -42,10 +42,15 @@
  *
  * @author Bruno Dumon
  * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
- * @version CVS $Id: Field.java,v 1.19 2004/07/11 17:18:26 vgritsenko Exp $
+ * @version CVS $Id$
  */
 public class Field extends AbstractWidget implements ValidationErrorAware, DataWidget, SelectableWidget,
         ValueChangedListenerEnabled {
+
+    private static final String FIELD_EL = "field";
+    private static final String VALUE_EL = "value";
+    private static final String VALIDATION_MSG_EL = "validation-message";
+
     /** Overrides selection list defined in FieldDefinition, if any. */
     protected SelectionList selectionList;
     /** Additional listeners to those defined as part of the widget definition (if any). */
@@ -170,13 +175,14 @@
     }
 
     public void readFromRequest(FormContext formContext) {
-        String newEnteredValue = formContext.getRequest().getParameter(getRequestParameterName());
-        // FIXME: Should we consider only non-null values, which allows to
-        // split a form across several screens?
-        //if (newEnteredValue != null) {
-            readFromRequest(newEnteredValue);
-        //}
-
+        if(getProcessRequests() == true) {
+            String newEnteredValue = formContext.getRequest().getParameter(getRequestParameterName());
+            // FIXME: Should we consider only non-null values, which allows to
+            // split a form across several screens?
+            //if (newEnteredValue != null) {
+                readFromRequest(newEnteredValue);
+            //}
+        }
     }
 
     protected void readFromRequest(String newEnteredValue) {
@@ -312,12 +318,6 @@
     public boolean isRequired() {
         return getFieldDefinition().isRequired();
     }
-
-
-    private static final String FIELD_EL = "field";
-    private static final String VALUE_EL = "value";
-    private static final String VALIDATION_MSG_EL = "validation-message";
-
 
     /**
      * @return "field"

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueField.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueField.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueField.java	Thu Sep  9 11:40:15 2004
@@ -47,9 +47,15 @@
  * can be used with the Datatype (see {@link org.apache.cocoon.forms.datatype.Datatype Datatype}
  * description for more information).
  * 
- * @version $Id: MultiValueField.java,v 1.13 2004/06/21 13:51:04 bruno Exp $
+ * @version $Id$
  */
 public class MultiValueField extends AbstractWidget implements ValidationErrorAware, SelectableWidget {
+
+    private static final String MULTIVALUEFIELD_EL = "multivaluefield";
+    private static final String VALUES_EL = "values";
+    private static final String VALUE_EL = "value";
+    private static final String VALIDATION_MSG_EL = "validation-message";
+
     private final MultiValueFieldDefinition definition;
     
     private SelectionList selectionList;
@@ -66,35 +72,38 @@
     }
 
     public void readFromRequest(FormContext formContext) {
-        enteredValues = formContext.getRequest().getParameterValues(getRequestParameterName());
-        validationError = null;
-        values = null;
-
-        boolean conversionFailed = false;
-        if (enteredValues != null) {
-            // Normally, for MultiValueFields, the user selects the values from
-            // a SelectionList, and the values in a SelectionList are garanteed to
-            // be valid, so the conversion from String to native datatype should
-            // never fail. But it could fail if users start messing around with
-            // request parameters.
-            Object[] tempValues = (Object[])Array.newInstance(getDatatype().getTypeClass(), enteredValues.length);
-            for (int i = 0; i < enteredValues.length; i++) {
-                String param = enteredValues[i];
-                ConversionResult conversionResult = definition.getDatatype().convertFromString(param, formContext.getLocale());
-                if (conversionResult.isSuccessful()) {
-                    tempValues[i] = conversionResult.getResult();
-                } else {
-                    conversionFailed = true;
-                    break;
+        if(getProcessRequests() == true) {
+            enteredValues = formContext.getRequest().getParameterValues(getRequestParameterName());
+            validationError = null;
+            values = null;
+ 
+            boolean conversionFailed = false;
+            if (enteredValues != null) {
+                // Normally, for MultiValueFields, the user selects the values from
+                // a SelectionList, and the values in a SelectionList are garanteed to
+                // be valid, so the conversion from String to native datatype should
+                // never fail. But it could fail if users start messing around with
+                // request parameters.
+                Object[] tempValues = (Object[])Array.newInstance(getDatatype().getTypeClass(), enteredValues.length);
+                for (int i = 0; i < enteredValues.length; i++) {
+                    String param = enteredValues[i];
+                    ConversionResult conversionResult =
+                        definition.getDatatype().convertFromString(param, formContext.getLocale());
+                    if (conversionResult.isSuccessful()) {
+                        tempValues[i] = conversionResult.getResult();
+                    } else {
+                        conversionFailed = true;
+                        break;
+                    }
                 }
+ 
+                if (!conversionFailed)
+                    values = tempValues;
+                else
+                    values = null;
+            } else {
+                values = new Object[0];
             }
-
-            if (!conversionFailed)
-                values = tempValues;
-            else
-                values = null;
-        } else {
-            values = new Object[0];
         }
     }
 
@@ -106,12 +115,6 @@
 
         return validationError == null ? super.validate() : false;
     }
-
-    private static final String MULTIVALUEFIELD_EL = "multivaluefield";
-    private static final String VALUES_EL = "values";
-    private static final String VALUE_EL = "value";
-    private static final String VALIDATION_MSG_EL = "validation-message";
-
 
     /**
      * @return "multivaluefield"

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Repeater.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Repeater.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Repeater.java	Thu Sep  9 11:40:15 2004
@@ -181,38 +181,40 @@
     }
     
     public void readFromRequest(FormContext formContext) {
-        // read number of rows from request, and make an according number of rows
-        String sizeParameter = formContext.getRequest().getParameter(getRequestParameterName() + ".size");
-        if (sizeParameter != null) {
-            int size = 0;
-            try {
-                size = Integer.parseInt(sizeParameter);
-            } catch (NumberFormatException exc) {
-                // do nothing
-            }
-
-            // some protection against people who might try to exhaust the server by supplying very large
-            // size parameters
-            if (size > 500)
-                throw new RuntimeException("Client is not allowed to specify a repeater size larger than 500.");
-
-            int currentSize = getSize();
-            if (currentSize < size) {
-                for (int i = currentSize; i < size; i++) {
-                    addRow();
+        if(getProcessRequests() == true) {
+            // read number of rows from request, and make an according number of rows
+            String sizeParameter = formContext.getRequest().getParameter(getRequestParameterName() + ".size");
+            if (sizeParameter != null) {
+                int size = 0;
+                try {
+                    size = Integer.parseInt(sizeParameter);
+                } catch (NumberFormatException exc) {
+                    // do nothing
                 }
-            } else if (currentSize > size) {
-                for (int i = currentSize - 1; i >= size; i--) {
-                    removeRow(i);
+ 
+                // some protection against people who might try to exhaust the server by supplying very large
+                // size parameters
+                if (size > 500)
+                    throw new RuntimeException("Client is not allowed to specify a repeater size larger than 500.");
+ 
+                int currentSize = getSize();
+                if (currentSize < size) {
+                    for (int i = currentSize; i < size; i++) {
+                        addRow();
+                    }
+                } else if (currentSize > size) {
+                    for (int i = currentSize - 1; i >= size; i--) {
+                        removeRow(i);
+                    }
                 }
             }
-        }
-
-        // let the rows read their data from the request
-        Iterator rowIt = rows.iterator();
-        while (rowIt.hasNext()) {
-            RepeaterRow row = (RepeaterRow)rowIt.next();
-            row.readFromRequest(formContext);
+ 
+            // let the rows read their data from the request
+            Iterator rowIt = rows.iterator();
+            while (rowIt.hasNext()) {
+                RepeaterRow row = (RepeaterRow)rowIt.next();
+                row.readFromRequest(formContext);
+            }
         }
     }
 

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Union.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Union.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Union.java	Thu Sep  9 11:40:15 2004
@@ -31,6 +31,7 @@
     //Note: union instances behave like simple "field" instance with respect to 
     //      XSLT post-processing, the choice of element-name reflects this.
     private static final String UNION_EL = "field";
+
     private Widget caseWidget;
     private String caseValue;
     
@@ -72,29 +73,31 @@
     }
 
     public void readFromRequest(FormContext formContext) {
-        // Ensure the case widget has read its value
-        caseWidget.readFromRequest(formContext);
-        
-        Widget widget;
-        // Read current case from request
-        String newValue = (String)getValue();
-        if (newValue != null && !newValue.equals("")) {
-            
-            if (getForm().getSubmitWidget() == caseWidget && !newValue.equals(caseValue)) {
-                // If submitted by the case widget and its value has changed, read the values
-                // for the previous case values. This allows to keep any entered values
-                // despite the case change.
-                widget = getChild(caseValue);
-            } else {
-                // Get the corresponding widget (will create it if needed)
-                widget = getChild(newValue);
-            }
-            
-            if (widget != null) {
-                widget.readFromRequest(formContext);
+        if(getProcessRequests() == true) {
+            // Ensure the case widget has read its value
+            caseWidget.readFromRequest(formContext);
+
+            Widget widget;
+            // Read current case from request
+            String newValue = (String)getValue();
+            if (newValue != null && !newValue.equals("")) {
+
+                if (getForm().getSubmitWidget() == caseWidget && !newValue.equals(caseValue)) {
+                    // If submitted by the case widget and its value has changed, read the values
+                    // for the previous case values. This allows to keep any entered values
+                    // despite the case change.
+                    widget = getChild(caseValue);
+                } else {
+                    // Get the corresponding widget (will create it if needed)
+                    widget = getChild(newValue);
+                }
+
+                if (widget != null) {
+                    widget.readFromRequest(formContext);
+                }
             }
+            caseValue = newValue;
         }
-        caseValue = newValue;
     }
 
     // TODO: Simplify this logic.

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Upload.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Upload.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Upload.java	Thu Sep  9 11:40:15 2004
@@ -35,9 +35,14 @@
  * 
  * @author <a href="mailto:uv@upaya.co.uk">Upayavira</a>
  * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
- * @version CVS $Id: Upload.java,v 1.13 2004/07/04 14:36:59 joerg Exp $
+ * @version CVS $Id$
  */
 public class Upload extends AbstractWidget implements ValidationErrorAware {
+
+    private static final String UPLOAD_EL = "upload";
+    private static final String VALUE_EL = "value";
+    private static final String VALIDATION_MSG_EL = "validation-message";
+
     private final UploadDefinition uploadDefinition;
     private Part part;
     private ValidationError validationError;
@@ -66,33 +71,35 @@
     }
 
     public void readFromRequest(FormContext formContext) {
-        Object obj = formContext.getRequest().get(getRequestParameterName());
-        
-        // If the request object is a Part, keep it
-        if (obj instanceof Part) {
-            Part requestPart = (Part)obj;
-            if (this.part != null) {
-                // Replace the current part
-                this.part.dispose();
-            }
-        
-            // Keep the request part
-            requestPart.setDisposeWithRequest(false);
-            this.part = requestPart;
-            this.validationError = null;
-            
-        // If it's not a part and not null, clear any existing value
-        // We also check if we're the submit widget, as a result of clicking the "..." button
-        } else if (obj != null || getForm().getSubmitWidget() == this){
-            // Clear the part, if any
-            if (this.part != null) {
-                this.part.dispose();
-                this.part = null;
+        if(getProcessRequests() == true) {
+            Object obj = formContext.getRequest().get(getRequestParameterName());
+
+            // If the request object is a Part, keep it
+            if (obj instanceof Part) {
+                Part requestPart = (Part)obj;
+                if (this.part != null) {
+                    // Replace the current part
+                    this.part.dispose();
+                }
+
+                // Keep the request part
+                requestPart.setDisposeWithRequest(false);
+                this.part = requestPart;
+                this.validationError = null;
+
+            // If it's not a part and not null, clear any existing value
+            // We also check if we're the submit widget, as a result of clicking the "..." button
+            } else if (obj != null || getForm().getSubmitWidget() == this){
+                // Clear the part, if any
+                if (this.part != null) {
+                    this.part.dispose();
+                    this.part = null;
+                }
+                this.validationError = null;
             }
-            this.validationError = null;
-        }
-        
-        // And keep the current state if the parameter doesn't exist or is null
+
+            // And keep the current state if the parameter doesn't exist or is null
+       }
     }
 
     public boolean validate() {
@@ -137,11 +144,6 @@
         this.validationError = error;
     }
 
-
-    private static final String UPLOAD_EL = "upload";
-    private static final String VALUE_EL = "value";
-    private static final String VALIDATION_MSG_EL = "validation-message";
-    
     /**
      * @return "upload"
      */

Modified: cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java
==============================================================================
--- cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java	(original)
+++ cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java	Thu Sep  9 11:40:15 2004
@@ -117,7 +117,19 @@
      *   of the path an invalid section was encountered. 
      */
     public Widget lookupWidget(String path);
-    
+
+    /**
+     * Returns whether {@link #readFromRequest(FormContext formContext)}
+     * processes the request parameter(s) for this widget.
+     */
+    public boolean getProcessRequests();
+
+    /**
+     * Controls whether {@link #readFromRequest(FormContext formContext)}
+     * processes the request parameter(s) for this widget.
+     */
+    public void setProcessRequests(boolean processRequests);
+
     /**
      * Lets this widget read its data from a request. At this point the Widget
      * may try to convert the request parameter to its native datatype (if it