Hi,

I've created a patch to set a visibilitystatus for widgets. This means that all widgets can be set visible or invisible on a form when a form is created or using flowscript.

Here is an example for making a form invisible when defining the form:
/    <fd:field id="other">
       <fd:label>Andere</fd:label>
       <fd:datatype base="string"/>
       <!-- make the form invisible to the user (This field is optional)-->
       <fd:visible value="false"/>
   </fd:field>/

And here an example to use it in flowscript (only implemented in V2 so far) / var form = new Form("someForm.xml");
var widget = form.getWidget();
// make other visible if invisible
widget.other.visible = true;


   // make other invisible if visible
   widget.other.visible = false;

   // get the current visibilitystatus for other
   var visibilityStatus = widget.other.visible;/

I've used the latest dev version from the apache svn repository to create this patch so currently it only works with the 2.2.0 dev version of cocoon.
The appended patch file contains all the changes I've made.


greets
Claudius

By the way  I've seen there are some references to my local filesystem
I hope these references are compatible/wont matter for applying the patch.
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
       (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
       (working copy)
@@ -68,6 +68,16 @@
      * Storage for the widget allocated attributes
      */
     private Map attributes;
+    
+    private boolean visible = true;
+    
+    public void setVisible(boolean visible) {
+       this.visible = visible;
+    }
+    
+    public boolean getVisible() {
+       return visible;
+    }
  
     /**
      * Called after widget's environment has been setup,
@@ -292,28 +302,32 @@
 
 
     public boolean validate() {
-        // Test validators from the widget definition
-        if (!getDefinition().validate(this)) {
-            // Failed
-            return false;
-        } else {
-            // Definition successful, test local validators
-            if (this.validators == null) {
-                // No local validators
-                return true;
-            } else {
-                // Iterate on local validators
-                Iterator iter = this.validators.iterator();
-                while(iter.hasNext()) {
-                    WidgetValidator validator = (WidgetValidator)iter.next();
-                    if (!validator.validate(this)) {
-                        return false;
-                    }
-                }
-                // All local iterators successful
-                return true;
-            }
-        }
+       if(getVisible() == true) {
+               // Test validators from the widget definition
+               if (!getDefinition().validate(this)) {
+                       // Failed
+                       return false;
+               } else {
+                       // Definition successful, test local validators
+                       if (this.validators == null) {
+                               // No local validators
+                               return true;
+                       } else {
+                               // Iterate on local validators
+                               Iterator iter = this.validators.iterator();
+                               while(iter.hasNext()) {
+                                       WidgetValidator validator = 
(WidgetValidator)iter.next();
+                                       if (!validator.validate(this)) {
+                                               return false;
+                                       }
+                               }
+                               // All local iterators successful
+                               return true;
+                       }
+               }
+       } else {
+               return true;
+       }
     }
 
     /**
@@ -329,7 +343,9 @@
      * @throws SAXException
      */
     public void generateLabel(ContentHandler contentHandler) throws SAXException {
-        getDefinition().generateDisplayData("label", contentHandler);
+       if(getVisible() == true) {
+               getDefinition().generateDisplayData("label", contentHandler);
+       }
     }
 
     /**
@@ -392,7 +408,9 @@
      * @see WidgetDefinition#generateDisplayData(ContentHandler) 
      */
     public void generateDisplayData(ContentHandler contentHandler) throws 
SAXException {
-        getDefinition().generateDisplayData(contentHandler);
+       if(getVisible() == true) {
+               getDefinition().generateDisplayData(contentHandler);
+       }
     }
 
     /**
@@ -418,15 +436,17 @@
      */
     public void generateSaxFragment(ContentHandler contentHandler, Locale locale)    
     throws SAXException {
-        String element = this.getXMLElementName();       
-        AttributesImpl attrs = getXMLElementAttributes();
-        contentHandler.startElement(Constants.INSTANCE_NS, element, 
Constants.INSTANCE_PREFIX_COLON + element, attrs);
+       if(getVisible() == true) {
+               String element = this.getXMLElementName();       
+               AttributesImpl attrs = getXMLElementAttributes();
+               contentHandler.startElement(Constants.INSTANCE_NS, element, 
Constants.INSTANCE_PREFIX_COLON + element, attrs);
 
-        generateDisplayData(contentHandler);
+               generateDisplayData(contentHandler);
         
-        generateItemSaxFragment(contentHandler, locale);
+               generateItemSaxFragment(contentHandler, locale);
         
-        contentHandler.endElement(Constants.INSTANCE_NS, element, 
Constants.INSTANCE_PREFIX_COLON + element);
+               contentHandler.endElement(Constants.INSTANCE_NS, element, 
Constants.INSTANCE_PREFIX_COLON + element);
+       }
     }
 
     public Object getAttribute(String name) {
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java
     (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java
     (working copy)
@@ -33,7 +33,7 @@
 /**
  * Provides functionality that is common across many WidgetDefinition implementations.
  * 
- * @version $Id: AbstractWidgetDefinition.java,v 1.7 2004/06/15 07:33:44 sylvain Exp $
+ * @version $Id$
  */
 public abstract class AbstractWidgetDefinition implements WidgetDefinition {
     private FormDefinition formDefinition;
@@ -42,6 +42,7 @@
     //TODO consider final on these
     private String location = null;
     private String id;
+    private boolean visible;
     private Map displayData;
     private List validators;
     
@@ -89,6 +90,14 @@
         this.id = id;
     }
     
+    public boolean getVisible() {
+       return visible;
+    }
+    
+    public void setVisible(boolean value) {
+       visible = value;
+    }
+    
     protected void addCreateListener(CreateListener listener) {
                this.createListener = WidgetEventMulticaster.add(this.createListener, 
listener);
     }
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
 (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/BooleanField.java
 (working copy)
@@ -55,6 +55,7 @@
 
     public BooleanField(BooleanFieldDefinition definition) {
         this.definition = definition;
+        setVisible(definition.getVisible());
     }
 
     protected WidgetDefinition getDefinition() {
@@ -114,17 +115,19 @@
     }
 
     public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) 
throws SAXException {
-        // value element
-        contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
-        String stringValue = String.valueOf(value != null && value.booleanValue() == 
true? "true": "false");
-        contentHandler.characters(stringValue.toCharArray(), 0, stringValue.length());
-        contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
-        // validation message element: only present if the value is not valid
-        if (validationError != null) {
-            contentHandler.startElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, 
Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL, XMLUtils.EMPTY_ATTRIBUTES);
-            validationError.generateSaxFragment(contentHandler);
-            contentHandler.endElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, 
Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
-        }
+       if(getVisible() == true) {
+               // value element
+               contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
+               String stringValue = String.valueOf(value != null && 
value.booleanValue() == true? "true": "false");
+               contentHandler.characters(stringValue.toCharArray(), 0, 
stringValue.length());
+               contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
+               // validation message element: only present if the value is not valid
+               if (validationError != null) {
+                       contentHandler.startElement(Constants.INSTANCE_NS, 
VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL, 
XMLUtils.EMPTY_ATTRIBUTES);
+                       validationError.generateSaxFragment(contentHandler);
+                       contentHandler.endElement(Constants.INSTANCE_NS, 
VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
+               }
+       }
     }
 
     public Object getValue() {
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java   
     (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Field.java   
     (working copy)
@@ -118,6 +118,7 @@
 
     public Field(FieldDefinition fieldDefinition) {
         this.fieldDefinition = fieldDefinition;
+        setVisible(fieldDefinition.getVisible());
     }
 
     public final FieldDefinition getFieldDefinition() {
@@ -211,23 +212,27 @@
     }
 
     public boolean validate() {
-        if (this.valueState == VALUE_UNPARSED) {
-            doParse();
-        }
+       if(getVisible() == true) {
+               if (this.valueState == VALUE_UNPARSED) {
+                       doParse();
+               }
 
-        // Force validation on already validated values (but keep invalid parsings)
-        if (this.valueState >= VALUE_VALIDATED) {
-            this.valueState = VALUE_PARSED;
-        }
+               // Force validation on already validated values (but keep invalid 
parsings)
+               if (this.valueState >= VALUE_VALIDATED) {
+                       this.valueState = VALUE_PARSED;
+               }
 
-        if (this.valueState == VALUE_PARSED) {
-            doValidate();
-            this.valueState = VALUE_DISPLAY_VALIDATION;
-        } else if (this.valueState == VALUE_PARSE_ERROR) {
-            this.valueState = VALUE_DISPLAY_PARSE_ERROR;
-        }
+               if (this.valueState == VALUE_PARSED) {
+                       doValidate();
+                       this.valueState = VALUE_DISPLAY_VALIDATION;
+               } else if (this.valueState == VALUE_PARSE_ERROR) {
+                       this.valueState = VALUE_DISPLAY_PARSE_ERROR;
+               }
 
-        return this.validationError == null;
+               return this.validationError == null;
+       } else {
+               return true;
+       }
     }
 
     /**
@@ -240,28 +245,30 @@
      *   validationError is set.
      */
     private void doParse() {
-        if (this.valueState != VALUE_UNPARSED) {
-            throw new IllegalStateException("Field is not in UNPARSED state (" + 
this.valueState + ")");
-        }
-        // Clear value, it will be recomputed
-        this.value = null;
-        this.validationError = null;
-        if (this.enteredValue != null) {
-            // Parse the value
-            ConversionResult conversionResult = 
getDatatype().convertFromString(this.enteredValue, getForm().getLocale());
-            if (conversionResult.isSuccessful()) {
-                this.value = conversionResult.getResult();
-                this.valueState = VALUE_PARSED;
-            } else {
-                // Conversion failed
-                this.validationError = conversionResult.getValidationError();
-                // No need for further validation (and need to keep the above error)
-                this.valueState = VALUE_PARSE_ERROR;
-            }
-        } else {
-            // No value: needs to be validated
-            this.valueState = VALUE_PARSED;
-        }
+       if(getVisible()) {
+               if (this.valueState != VALUE_UNPARSED) {
+                       throw new IllegalStateException("Field is not in UNPARSED 
state (" + this.valueState + ")");
+               }
+               // Clear value, it will be recomputed
+               this.value = null;
+               this.validationError = null;
+               if (this.enteredValue != null) {
+                       // Parse the value
+                       ConversionResult conversionResult = 
getDatatype().convertFromString(this.enteredValue, getForm().getLocale());
+                       if (conversionResult.isSuccessful()) {
+                               this.value = conversionResult.getResult();
+                               this.valueState = VALUE_PARSED;
+                       } else {
+                               // Conversion failed
+                               this.validationError = 
conversionResult.getValidationError();
+                               // No need for further validation (and need to keep 
the above error)
+                               this.valueState = VALUE_PARSE_ERROR;
+                       }
+               } else {
+                       // No value: needs to be validated
+                       this.valueState = VALUE_PARSED;
+               }
+       }
     }
 
     /**
@@ -271,27 +278,29 @@
      * validation failed.
      */
     private void doValidate() {
-        if (this.valueState != VALUE_PARSED) {
-            throw new IllegalStateException("Field is not in PARSED state (" + 
this.valueState + ")");
-        }
+       if(getVisible() == true) {
+               if (this.valueState != VALUE_PARSED) {
+                       throw new IllegalStateException("Field is not in PARSED state 
(" + this.valueState + ")");
+               }
 
-        // Go to transient validating state
-        this.valueState = VALUE_VALIDATING;
+               // Go to transient validating state
+               this.valueState = VALUE_VALIDATING;
 
-        try {
-            if (this.value == null && getFieldDefinition().isRequired()) {
-                // Field is required
-                this.validationError = new ValidationError(new 
I18nMessage("general.field-required", Constants.I18N_CATALOGUE));
-            } else {
-                if (super.validate()) {
-                    // New-style validators were successful. Check the old-style ones.
-                    this.validationError = getDatatype().validate(value, new 
ExpressionContextImpl(this));
-                }
-            }
-        } finally {
-            // Consider validation finished even in case of exception
-            this.valueState = VALUE_VALIDATED;
-        }
+               try {
+                       if (this.value == null && getFieldDefinition().isRequired()) {
+                               // Field is required
+                               this.validationError = new ValidationError(new 
I18nMessage("general.field-required", Constants.I18N_CATALOGUE));
+                       } else {
+                               if (super.validate()) {
+                                       // New-style validators were successful. Check 
the old-style ones.
+                                       this.validationError = 
getDatatype().validate(value, new ExpressionContextImpl(this));
+                               }
+                       }
+               } finally {
+                       // Consider validation finished even in case of exception
+                       this.valueState = VALUE_VALIDATED;
+               }
+       }
     }
 
     /**
@@ -336,34 +345,36 @@
     }
 
     public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) 
throws SAXException {
-        if (enteredValue != null || value != null) {
-            contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
-            String stringValue;
-            if (value != null) {
-                stringValue = getDatatype().convertToString(value, locale);
-            } else {
-                stringValue = enteredValue;
-            }
-            contentHandler.characters(stringValue.toCharArray(), 0, 
stringValue.length());
-            contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
-        }
+       if(getVisible() == true) {
+               if (enteredValue != null || value != null) {
+                       contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
+                       String stringValue;
+                       if (value != null) {
+                               stringValue = getDatatype().convertToString(value, 
locale);
+                       } else {
+                               stringValue = enteredValue;
+                       }
+                       contentHandler.characters(stringValue.toCharArray(), 0, 
stringValue.length());
+               contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
+               }
 
-        // validation message element: only present if the value is not valid
-        if (validationError != null && (this.valueState == VALUE_DISPLAY_VALIDATION 
|| this.valueState == VALUE_DISPLAY_PARSE_ERROR)) {
-            contentHandler.startElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, 
Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL, XMLUtils.EMPTY_ATTRIBUTES);
-            validationError.generateSaxFragment(contentHandler);
-            contentHandler.endElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, 
Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
-        }
+               // validation message element: only present if the value is not valid
+               if (validationError != null && (this.valueState == 
VALUE_DISPLAY_VALIDATION || this.valueState == VALUE_DISPLAY_PARSE_ERROR)) {
+                       contentHandler.startElement(Constants.INSTANCE_NS, 
VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL, 
XMLUtils.EMPTY_ATTRIBUTES);
+                       validationError.generateSaxFragment(contentHandler);
+                       contentHandler.endElement(Constants.INSTANCE_NS, 
VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
+               }
 
-        // generate selection list, if any
-        if (selectionList != null) {
-            selectionList.generateSaxFragment(contentHandler, locale);
-        } else if (getFieldDefinition().getSelectionList() != null) {
-            
getFieldDefinition().getSelectionList().generateSaxFragment(contentHandler, locale);
-        }
+               // generate selection list, if any
+               if (selectionList != null) {
+                       selectionList.generateSaxFragment(contentHandler, locale);
+               } else if (getFieldDefinition().getSelectionList() != null) {
+                       
getFieldDefinition().getSelectionList().generateSaxFragment(contentHandler, locale);
+               }
 
-        // include some info about the datatype
-        fieldDefinition.getDatatype().generateSaxFragment(contentHandler, locale);
+               // include some info about the datatype
+               fieldDefinition.getDatatype().generateSaxFragment(contentHandler, 
locale);
+       }
     }
 
 
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java  
     (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Widget.java  
     (working copy)
@@ -225,4 +225,14 @@
      * @param name of the attribute
      */
     public void removeAttribute(String name);
+    
+    /**
+     * Sets wether a widget is visible or not.
+     */
+    public void setVisible(boolean visible);
+    
+    /**
+     * Returns wether a widget is visible or not.
+     */
+    public boolean getVisible();
 }
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java
     (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java
     (working copy)
@@ -24,7 +24,7 @@
  * usually won't have to bother with the WidgetDefinition's, but will rather use
  * the Widget's themselves.
  * 
- * @version CVS $Id: WidgetDefinition.java,v 1.5 2004/04/29 08:46:19 cziegeler Exp $
+ * @version CVS $Id$
  */
 public interface WidgetDefinition {
 
@@ -49,6 +49,11 @@
     public String getId();
     
     /**
+     * Returns wether a widget is visible or not.
+     */
+    public boolean getVisible();
+    
+    /**
      * Validate a widget using the validators that were defined in its definition. If 
validation
      * fails, the validator has set a validation error on the widget or one of its 
children.
      * 
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Output.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Output.java  
     (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/Output.java  
     (working copy)
@@ -31,7 +31,7 @@
  *
  * <p>An Output widget is always valid and never required.
  * 
- * @version $Id: Output.java,v 1.9 2004/05/07 13:42:09 mpo Exp $
+ * @version $Id$
  */
 public class Output extends AbstractWidget implements DataWidget {
     
@@ -48,6 +48,7 @@
 
     protected Output(OutputDefinition definition) {
         this.definition = definition;
+        setVisible(definition.getVisible());
     }
 
     protected WidgetDefinition getDefinition() {
@@ -74,14 +75,16 @@
     }
 
     public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) 
throws SAXException {
-        // the value
-        if (value != null) {
-            contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
-            String stringValue;
-            stringValue = definition.getDatatype().convertToString(value, locale);
-            contentHandler.characters(stringValue.toCharArray(), 0, 
stringValue.length());
-            contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
-        }
+       if(getVisible() == true) {
+               // the value
+               if (value != null) {
+                       contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
+                       String stringValue;
+                       stringValue = definition.getDatatype().convertToString(value, 
locale);
+                       contentHandler.characters(stringValue.toCharArray(), 0, 
stringValue.length());
+                       contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
+               }
+       }
     }
 
     public Object getValue() {
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
      (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
      (working copy)
@@ -118,6 +118,7 @@
     protected void setDisplayData(Element widgetElement, AbstractWidgetDefinition 
widgetDefinition) throws Exception {
         final String[] names = {"label", "help", "hint"};
         Map displayData = new HashMap(names.length);
+        
         for (int i = 0; i < names.length; i++) {
             XMLizable data = null;
             Element dataElement = DomHelper.getChildElement(widgetElement, 
Constants.DEFINITION_NS, names[i]);
@@ -129,6 +130,15 @@
             //       (see AbstractWidgetDefinition.generateDisplayData)
             displayData.put(names[i], data);
         }
+        
+        Element visibleElement = DomHelper.getChildElement(widgetElement, 
+                       Constants.DEFINITION_NS, "visible" );
+        if(visibleElement != null) {
+               Boolean boolval = new Boolean(visibleElement.getAttribute("value"));
+               widgetDefinition.setVisible(boolval.booleanValue());
+        } else {
+               widgetDefinition.setVisible(true);
+        }
 
         widgetDefinition.setDisplayData(displayData);
     }
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java
       (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AggregateField.java
       (working copy)
@@ -233,4 +233,8 @@
     public Widget getChild(String id) {
         return (Widget)fieldsById.get(id);
     }
+    
+    public void setVisible(boolean value) {
+       return;
+    }
 }
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueField.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueField.java
      (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/MultiValueField.java
      (working copy)
@@ -65,6 +65,7 @@
 
     public MultiValueField(MultiValueFieldDefinition definition) {
         this.definition = definition;
+        setVisible(definition.getVisible());
     }
 
     protected WidgetDefinition getDefinition() {
@@ -108,12 +109,16 @@
     }
 
     public boolean validate() {
-        if (values != null)
-            validationError = definition.getDatatype().validate(values, new 
ExpressionContextImpl(this));
-        else
-            validationError = new ValidationError(new 
I18nMessage("multivaluefield.conversionfailed", Constants.I18N_CATALOGUE));
+       if(getVisible() == true) {
+               if (values != null)
+                       validationError = definition.getDatatype().validate(values, 
new ExpressionContextImpl(this));
+               else
+                       validationError = new ValidationError(new 
I18nMessage("multivaluefield.conversionfailed", Constants.I18N_CATALOGUE));
 
-        return validationError == null ? super.validate() : false;
+               return validationError == null ? super.validate() : false;
+       } else {
+               return true;
+       }
     }
 
     /**
@@ -124,37 +129,39 @@
     }   
     
     public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) 
throws SAXException {
-        contentHandler.startElement(Constants.INSTANCE_NS, VALUES_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUES_EL, XMLUtils.EMPTY_ATTRIBUTES);
-        if (values != null) {
-            for (int i = 0; i < values.length; i++) {
-                contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
-                String value = 
definition.getDatatype().getPlainConvertor().convertToString(values[i], locale, null);
-                contentHandler.characters(value.toCharArray(), 0, value.length());
-                contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
-            }
-        } else if (enteredValues != null) {
-            for (int i = 0; i < enteredValues.length; i++) {
-                contentHandler.startElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
-                String value = 
definition.getDatatype().getPlainConvertor().convertToString(enteredValues[i], locale, 
null);
-                contentHandler.characters(value.toCharArray(), 0, value.length());
-                contentHandler.endElement(Constants.INSTANCE_NS, VALUE_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
-            }
-        }
-        contentHandler.endElement(Constants.INSTANCE_NS, VALUES_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUES_EL);
+       if(getVisible() == true) {
+               contentHandler.startElement(Constants.INSTANCE_NS, VALUES_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUES_EL, XMLUtils.EMPTY_ATTRIBUTES);
+               if (values != null) {
+                       for (int i = 0; i < values.length; i++) {
+                               contentHandler.startElement(Constants.INSTANCE_NS, 
VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
+                               String value = 
definition.getDatatype().getPlainConvertor().convertToString(values[i], locale, null);
+                               contentHandler.characters(value.toCharArray(), 0, 
value.length());
+                               contentHandler.endElement(Constants.INSTANCE_NS, 
VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
+                       }
+               } else if (enteredValues != null) {
+                       for (int i = 0; i < enteredValues.length; i++) {
+                               contentHandler.startElement(Constants.INSTANCE_NS, 
VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL, XMLUtils.EMPTY_ATTRIBUTES);
+                               String value = 
definition.getDatatype().getPlainConvertor().convertToString(enteredValues[i], locale, 
null);
+                               contentHandler.characters(value.toCharArray(), 0, 
value.length());
+                               contentHandler.endElement(Constants.INSTANCE_NS, 
VALUE_EL, Constants.INSTANCE_PREFIX_COLON + VALUE_EL);
+                       }
+               }
+               contentHandler.endElement(Constants.INSTANCE_NS, VALUES_EL, 
Constants.INSTANCE_PREFIX_COLON + VALUES_EL);
 
-        // the selection list (a MultiValueField has per definition always a 
SelectionList)
-        if (this.selectionList != null) {
-            this.selectionList.generateSaxFragment(contentHandler, locale);
-        } else {
-            definition.getSelectionList().generateSaxFragment(contentHandler, locale);
-        }
+               // the selection list (a MultiValueField has per definition always a 
SelectionList)
+               if (this.selectionList != null) {
+                       this.selectionList.generateSaxFragment(contentHandler, locale);
+               } else {
+                       
definition.getSelectionList().generateSaxFragment(contentHandler, locale);
+               }
 
-        // validation message element
-        if (validationError != null) {
-            contentHandler.startElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, 
Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL, XMLUtils.EMPTY_ATTRIBUTES);
-            validationError.generateSaxFragment(contentHandler);
-            contentHandler.endElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, 
Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
-        }
+               // validation message element
+               if (validationError != null) {
+                       contentHandler.startElement(Constants.INSTANCE_NS, 
VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL, 
XMLUtils.EMPTY_ATTRIBUTES);
+                       validationError.generateSaxFragment(contentHandler);
+                       contentHandler.endElement(Constants.INSTANCE_NS, 
VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
+               }
+       }
     }
 
     
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerWidget.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerWidget.java
      (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerWidget.java
      (working copy)
@@ -115,4 +115,12 @@
     public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) 
throws SAXException {
         widgets.generateSaxFragment(contentHandler, locale);
     }
+    
+    public void setVisible(boolean value) {
+       return;
+    }
+    
+    public boolean getVisible() {
+       return true;
+    }
 }
Index: 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v2/ScriptableWidget.java
===================================================================
--- 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v2/ScriptableWidget.java
    (revision 46930)
+++ 
C:/svnroot/cocoon/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/v2/ScriptableWidget.java
    (working copy)
@@ -53,7 +53,7 @@
 import java.util.HashMap;
 
 /**
- * @version $Id: ScriptableWidget.java,v 1.12 2004/05/11 09:30:24 mpo Exp $
+ * @version $Id$
  * 
  */
 public class ScriptableWidget extends ScriptableObject {
@@ -290,6 +290,14 @@
         }
         super.delete(index);
     }
+    
+    public void jsSet_visible(Object value) {
+       delegate.setVisible(((Boolean)value).booleanValue());
+    }
+    
+    public Object jsGet_visible() {
+       return new Boolean(delegate.getVisible());
+    }
 
     public Object jsGet_value() {
         return delegate.getValue();

Reply via email to