cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpfingsth...@apache.org
Subject svn commit: r239967 - in /cocoon/gsoc/mpfingsthorn/forms: WEB-INF/xconf/ java/org/apache/cocoon/forms/formmodel/ samples/library/ samples/library/forms/ samples/library/libraries/
Date Wed, 24 Aug 2005 23:46:04 GMT
Author: mpfingsthorn
Date: Wed Aug 24 16:45:25 2005
New Revision: 239967

URL: http://svn.apache.org/viewcvs?rev=239967&view=rev
Log:
New ExpandDefinition(Builder) to instantiate a non-class widget from the library. Also, inheritance
works, by use of the "extends" attribute, specifying the id to load from the library (or local
form definition).

Added:
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java
Modified:
    cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/cocoon-forms.xconf
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/NewDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
    cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_binding.xml
    cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_model.xml
    cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_template.xml
    cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/library_form1.xml
    cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap

Modified: cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/cocoon-forms.xconf
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/cocoon-forms.xconf?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/cocoon-forms.xconf (original)
+++ cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/cocoon-forms.xconf Wed Aug 24 16:45:25 2005
@@ -139,6 +139,7 @@
     <widgets>
       <widget name="form" src="org.apache.cocoon.forms.formmodel.FormDefinitionBuilder"/>
       <widget name="import" src="org.apache.cocoon.forms.formmodel.ImportDefinitionBuilder"/>
+      <widget name="expand" src="org.apache.cocoon.forms.formmodel.ExpandDefinitionBuilder"/>
       <widget name="field" src="org.apache.cocoon.forms.formmodel.FieldDefinitionBuilder"/>
       <widget name="group" src="org.apache.cocoon.forms.formmodel.GroupDefinitionBuilder"/>
       <widget name="repeater" src="org.apache.cocoon.forms.formmodel.RepeaterDefinitionBuilder"/>

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinition.java
Wed Aug 24 16:45:25 2005
@@ -41,6 +41,26 @@
     }
     
     /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof AbstractContainerDefinition) {
+    		AbstractContainerDefinition other = (AbstractContainerDefinition)definition;
+    		
+    		Iterator otherwidgets = other.definitions.getWidgetDefinitions().iterator();
+    		while(otherwidgets.hasNext()) {
+    			try {
+    				this.definitions.addWidgetDefinition((WidgetDefinition)otherwidgets.next());
+    			} catch(DuplicateIdException ignore) {}
+    		}
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
+    
+    /**
      * checks completeness of this definition
      */
     public void checkCompleteness() throws IncompletenessException {

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.java
Wed Aug 24 16:45:25 2005
@@ -22,9 +22,9 @@
             WidgetDefinition def = null;
             if(this.context !=null)
 	            if((newId = (String)widgetElement.getAttribute("extends")) != null) {
-	            	if((def = definition.getWidgetDefinition(newId))!=null)
+	            	if((def = this.context.getLocalLibrary().getDefinition(newId))!=null)
 	            		this.context.setSuperDefinition(def);
-	            	else if((def = this.context.getLocalLibrary().getDefinition(newId))!=null)
+	            	else if((def = definition.getWidgetDefinition(newId))!=null)
 	            		this.context.setSuperDefinition(def);
 	            }
 	            else

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractDatatypeWidgetDefinition.java
Wed Aug 24 16:45:25 2005
@@ -54,6 +54,25 @@
     		throw new IncompletenessException("A datatype element is required!",this);
     	
     }
+    
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof AbstractDatatypeWidgetDefinition) {
+    		AbstractDatatypeWidgetDefinition other = (AbstractDatatypeWidgetDefinition)definition;
+    		
+    		this.datatype = other.datatype;
+    		this.initialValue = other.initialValue;
+    		this.selectionList = other.selectionList;
+    		this.listener = other.listener;
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
 
     public Datatype getDatatype() {
         return datatype;

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinition.java
Wed Aug 24 16:45:25 2005
@@ -16,6 +16,8 @@
 package org.apache.cocoon.forms.formmodel;
 
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -61,6 +63,52 @@
             }
         }
         return this.formDefinition;
+    }
+    
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	System.out.println("Init from def: "+definition);
+    	if(definition instanceof AbstractWidgetDefinition) {
+    		AbstractWidgetDefinition other = (AbstractWidgetDefinition)definition;
+    		
+    		this.state = other.state;
+    		this.createListener = other.createListener; // this works, we don't really remove listeners,
right?
+    		
+    		this.validators = new ArrayList();
+    		if(other.validators!=null) {
+    			Collections.copy(this.validators,other.validators);
+    		}
+    		
+    		if(other.attributes!=null) {
+    			if(attributes==null)
+    				attributes = new HashMap();
+    	    	copyMap(attributes,other.attributes);
+    		}
+    		if(other.displayData!=null) {
+    			if(displayData==null)
+    				displayData = new HashMap();
+    	    	copyMap(displayData,other.displayData);
+    		}
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
+    
+    /**
+     * helper to copy a map
+     * 
+     * @param dest destination map
+     * @param src source map
+     */
+    protected void copyMap(Map dest, Map src) {
+    	dest.clear();
+    	Iterator it = src.entrySet().iterator();
+    	while(it.hasNext()) {
+    		Map.Entry entry = (Map.Entry)it.next();
+    		dest.put(entry.getKey(),entry.getValue());
+    	}
     }
     
     /**

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractWidgetDefinitionBuilder.java
Wed Aug 24 16:45:25 2005
@@ -81,14 +81,19 @@
     }
     
     protected void setupDefinition(Element widgetElement, AbstractWidgetDefinition definition)
throws Exception {
+    	
+    	// location
+    	definition.setLocation(DomHelper.getLocation(widgetElement));
+    	
+    	if(this.context.getSuperDefinition()!=null)
+    		definition.initializeFrom(this.context.getSuperDefinition());
+    	
         setCommonProperties(widgetElement, definition);
         setValidators(widgetElement, definition);
         setCreateListeners(widgetElement, definition);
     }
 
     private void setCommonProperties(Element widgetElement, AbstractWidgetDefinition widgetDefinition)
throws Exception {
-        // location
-        widgetDefinition.setLocation(DomHelper.getLocation(widgetElement));
         
         // id
         if (widgetDefinition instanceof FormDefinition) {

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ActionDefinition.java
Wed Aug 24 16:45:25 2005
@@ -31,6 +31,23 @@
     public void setActionCommand(String actionCommand) {
         this.actionCommand = actionCommand;
     }
+    
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof ActionDefinition) {
+    		ActionDefinition other = (ActionDefinition)definition;
+    		
+    		this.actionCommand = other.actionCommand;
+    		this.listener = other.listener;
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
 
     public String getActionCommand() {
         return actionCommand;

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AggregateFieldDefinition.java
Wed Aug 24 16:45:25 2005
@@ -21,6 +21,7 @@
 import org.outerj.expression.Expression;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -71,6 +72,36 @@
      */
     private WidgetDefinitionList container = new WidgetDefinitionList(this);
 
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof AggregateFieldDefinition) {
+    		AggregateFieldDefinition other = (AggregateFieldDefinition)definition;
+    		
+    		this.combineExpr = other.combineExpr;
+    		this.splitRegexp = other.splitRegexp;
+    		this.splitPattern = other.splitPattern;
+    		this.splitFailMessage = other.splitFailMessage;
+    		
+    		Iterator defs = other.container.getWidgetDefinitions().iterator();
+    		while(defs.hasNext()) {
+    			container.addWidgetDefinition((WidgetDefinition)defs.next());
+    		}
+    		
+    		Collections.copy(this.splitMappings,other.splitMappings);
+    		
+    		Iterator fields = other.mappedFields.iterator();
+    		while(fields.hasNext()) {
+    			this.mappedFields.add(fields.next());
+    		}
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
 
     public void addWidgetDefinition(WidgetDefinition widgetDefinition) throws DuplicateIdException
{
         checkMutable();

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/BooleanFieldDefinition.java
Wed Aug 24 16:45:25 2005
@@ -35,6 +35,24 @@
         return new BooleanField(this);
     }
     
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof BooleanFieldDefinition) {
+    		BooleanFieldDefinition other = (BooleanFieldDefinition)definition;
+    		
+    		this.listener = other.listener;
+    		this.initialValue = other.initialValue;
+    		this.trueParamValue = other.trueParamValue;
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
+    
     public void setInitialValue(Boolean value) {
         checkMutable();
         this.initialValue = value;

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/CaptchaFieldDefinition.java
Wed Aug 24 16:45:25 2005
@@ -31,6 +31,22 @@
     public CaptchaFieldDefinition(Context avalonContext) {
         this.avalonContext = avalonContext;
     }
+    
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof CaptchaFieldDefinition) {
+    		CaptchaFieldDefinition other = (CaptchaFieldDefinition)definition;
+    		
+    		this.length = other.length;
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
 
     public Widget createInstance() {
         CaptchaField field = new CaptchaField(this, avalonContext);

Added: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinition.java?rev=239967&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinition.java
(added)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinition.java
Wed Aug 24 16:45:25 2005
@@ -0,0 +1,90 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.formmodel;
+
+import java.util.List;
+import java.util.ListIterator;
+
+// TODO: The exception messages should use I18n.
+/**
+ * This is the "{@link WidgetDefinition}" which is used to instantiate a
+ * definition from a library which is not a {@link ClassDefinition}. 
+ * The resolve step replaces this definition with
+ * the definition contained in the referenced {@link Library}.
+ * 
+ * Taken from NewDefinition
+ *
+ * @version $Id: ExpandDefinition 46126 2004-09-15 18:42:28Z tim $
+ */
+public class ExpandDefinition extends AbstractWidgetDefinition {
+    private boolean resolving;
+    private WidgetDefinition widgetDefinition;
+
+    public ExpandDefinition() {
+        super();
+        resolving = false;
+        widgetDefinition = null;
+    }
+
+    private WidgetDefinition getWidgetDefinition() throws Exception {
+        FormDefinition formDefinition = getFormDefinition();
+        
+        widgetDefinition = formDefinition.getLocalLibrary().getDefinition(getId());
+        
+        if (widgetDefinition == null)
+            throw new Exception("ExpandDefinition: Widget with id \"" + getId() + "\" does
not exist (" + getLocation() + ")");
+
+        return widgetDefinition;
+    }
+
+    // TODO: Should add checking for union defaults which would cause non-terminating recursion.
+    public void resolve(List parents, WidgetDefinition parent) throws Exception {
+        // Non-terminating recursion detection
+        if (resolving) {
+            // Search up parent list in hopes of finding a "Union" before finding previous
"Expand" for this "Class".
+            ListIterator parentsIt = parents.listIterator(parents.size());
+            while(parentsIt.hasPrevious()) {
+                WidgetDefinition definition = (WidgetDefinition)parentsIt.previous();
+                if (definition instanceof UnionDefinition) break;
+                if (definition == this)
+                    throw new Exception("ExpandDefinition: Non-terminating recursion detected
in widget definition : "
+                        + parent.getId() + " (" + getLocation() + ")");
+            }
+        }
+        // Resolution
+        resolving = true;
+        //parents.add(this);
+        widgetDefinition = getWidgetDefinition();
+        parents.add(this);
+        
+        if (widgetDefinition instanceof ContainerDefinition) {
+            ((ContainerDefinition)widgetDefinition).resolve(parents, parent);
+        } else if (widgetDefinition instanceof ExpandDefinition) {
+            ((ExpandDefinition)widgetDefinition).resolve(parents, parent);
+        } else if (widgetDefinition instanceof NewDefinition) {
+            ((NewDefinition)widgetDefinition).resolve(parents, parent);
+        } else {
+            ((ContainerDefinition)parent).addWidgetDefinition(widgetDefinition);
+        }
+        
+        parents.remove(parents.size()-1);
+        resolving = false;
+    }
+
+    public Widget createInstance() {
+        return null;
+    }
+}

Added: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java?rev=239967&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java
(added)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ExpandDefinitionBuilder.java
Wed Aug 24 16:45:25 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.forms.formmodel;
+
+import org.w3c.dom.Element;
+
+/**
+ * Builds {NewDefinition}s.
+ *
+ * @version $Id: NewDefinitionBuilder.java 155211 2005-02-24 17:05:51Z sylvain $
+ */
+public class ExpandDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
+
+    public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
+        ExpandDefinition definition = new ExpandDefinition();
+        setupDefinition(element, definition);
+        definition.makeImmutable();
+        
+        return definition;
+    }
+}

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FieldDefinition.java
Wed Aug 24 16:45:25 2005
@@ -27,6 +27,22 @@
         Field field = new Field(this);
         return field;
     }
+    
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof FieldDefinition) {
+    		FieldDefinition other = (FieldDefinition)definition;
+    		
+    		this.required = other.required;
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
 
     public boolean isRequired() {
         return required;

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/NewDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/NewDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/NewDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/NewDefinition.java
Wed Aug 24 16:45:25 2005
@@ -75,9 +75,10 @@
             WidgetDefinition definition = (WidgetDefinition)definitionsIt.next();
             if (definition instanceof ContainerDefinition) {
                 ((ContainerDefinition)definition).resolve(parents, parent);
-            }
-            if (definition instanceof NewDefinition) {
+            } else if (definition instanceof NewDefinition) {
                 ((NewDefinition)definition).resolve(parents, parent);
+            } else if (definition instanceof ExpandDefinition) {
+                ((ExpandDefinition)definition).resolve(parents, parent);
             } else {
                 ((ContainerDefinition)parent).addWidgetDefinition(definition);
             }

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java
Wed Aug 24 16:45:25 2005
@@ -43,6 +43,22 @@
     public RepeaterActionDefinition(String repeaterName) {
         this.name = repeaterName;
     }
+    
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof RepeaterActionDefinition) {
+    		RepeaterActionDefinition other = (RepeaterActionDefinition)definition;
+    		
+    		this.name = other.name;
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
 
     public Widget createInstance() {
         return new RepeaterAction(this);
@@ -76,6 +92,22 @@
             this.selectName = selectName;
         }
 
+        /**
+         * initialize this definition with the other, sort of like a copy constructor
+         */
+        public void initializeFrom(WidgetDefinition definition) throws Exception {
+        	super.initializeFrom(definition);
+        	
+        	if(definition instanceof DeleteRowsActionDefinition) {
+        		DeleteRowsActionDefinition other = (DeleteRowsActionDefinition)definition;
+        		
+        		this.selectName = other.selectName;
+        		
+        	} else {
+        		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+        	}
+        }
+        
         public boolean hasActionListeners() {
             // we always want to be notified
             return true;
@@ -124,6 +156,22 @@
     public static class InsertRowsActionDefinition extends RepeaterActionDefinition {
         
         private String selectName;
+        
+        /**
+         * initialize this definition with the other, sort of like a copy constructor
+         */
+        public void initializeFrom(WidgetDefinition definition) throws Exception {
+        	super.initializeFrom(definition);
+        	
+        	if(definition instanceof InsertRowsActionDefinition) {
+        		InsertRowsActionDefinition other = (InsertRowsActionDefinition)definition;
+        		
+        		this.selectName = other.selectName;
+        		
+        	} else {
+        		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+        	}
+        }
         
         public InsertRowsActionDefinition(String repeaterName, String selectWidgetName) {
             super(repeaterName);

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
Wed Aug 24 16:45:25 2005
@@ -27,6 +27,21 @@
         super();
         this.initialSize = initialSize;
     }
+    
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof RepeaterDefinition) {
+    		RepeaterDefinition other = (RepeaterDefinition)definition;
+    		
+    		this.initialSize = other.initialSize;
+    	} else {
+     		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+     	}
+    }
 
     public Widget createInstance() {
         return new Repeater(this);

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java
Wed Aug 24 16:45:25 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+
 /**
  * Definition for a {@link Submit}.
  * 
@@ -25,6 +26,22 @@
 public class SubmitDefinition extends ActionDefinition {
     
     private boolean validateForm;
+    
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof SubmitDefinition) {
+    		SubmitDefinition other = (SubmitDefinition)definition;
+    		
+    		this.validateForm = other.validateForm;
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
     
     public void setValidateForm(boolean validateForm) {
         checkMutable();

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java
Wed Aug 24 16:45:25 2005
@@ -49,6 +49,21 @@
         return defaultValue;
     }
     */
+    
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof UnionDefinition) {
+    		UnionDefinition other = (UnionDefinition)definition;
+    		this.caseWidgetId = other.caseWidgetId;
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
 
     public void setCaseWidgetId(String id) {
         checkMutable();

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java
Wed Aug 24 16:45:25 2005
@@ -36,6 +36,23 @@
         this.mimeTypes = mimeTypes;
     }
     
+    /**
+     * initialize this definition with the other, sort of like a copy constructor
+     */
+    public void initializeFrom(WidgetDefinition definition) throws Exception {
+    	super.initializeFrom(definition);
+    	
+    	if(definition instanceof UploadDefinition) {
+    		UploadDefinition other = (UploadDefinition)definition;
+    		
+    		this.required = other.required;
+    		this.mimeTypes = other.mimeTypes;
+    		
+    	} else {
+    		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+    	}
+    }
+    
     public void addMimeTypes(String types) {
     	if(types != null) {
     		if(mimeTypes == null)

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java
Wed Aug 24 16:45:25 2005
@@ -28,6 +28,11 @@
  */
 public interface WidgetDefinition {
 
+	/**
+	 * Initializes this definition with values from the given other definition
+	 */
+	void initializeFrom(WidgetDefinition definition) throws Exception;
+	
     /**
      * Gets the {@link FormDefinition}.
      */

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
(original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
Wed Aug 24 16:45:25 2005
@@ -96,6 +96,10 @@
                         // Remove NewDefinition in preparation for its referenced class of
widget definitions to be added.
                         this.definitionsIt.remove();
                         ((NewDefinition)widgetDefinition).resolve(parents, containerDefinition);
+                    } else if(widgetDefinition instanceof ExpandDefinition) {
+                    	// Remove ExpandDefinition in preparation for its referenced widget
definition to be added.
+                        this.definitionsIt.remove();
+                        ((ExpandDefinition)widgetDefinition).resolve(parents, containerDefinition);
                     } else {
                         if (widgetDefinition instanceof ContainerDefinition)
                             ((ContainerDefinition)widgetDefinition).resolve(parents, containerDefinition);

Modified: cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_binding.xml
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_binding.xml?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_binding.xml (original)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_binding.xml Wed Aug 24 16:45:25
2005
@@ -20,5 +20,7 @@
   path="/data" >
   
   <fb:value id="field1" path="field1"/>
+  <fb:value id="field2" path="field2"/>
+  <fb:value id="field3" path="field3"/>
   
 </fb:context>

Modified: cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_model.xml
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_model.xml?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_model.xml (original)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_model.xml Wed Aug 24 16:45:25
2005
@@ -22,5 +22,11 @@
     <fd:import prefix="lib" uri="cocoon:/library/library_form1.xml"/>
     
     <fd:new id="lib:class1"/>
+    <fd:expand id="lib:field2"/>
+    
+    <fd:field id="field3" extends="lib:field2">
+      <fd:datatype base="integer"/>
+    </fd:field>
+    
   </fd:widgets>
 </fd:form>

Modified: cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_template.xml
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_template.xml?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_template.xml (original)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_template.xml Wed Aug 24 16:45:25
2005
@@ -23,6 +23,8 @@
         <fi:styling layout="columns"/>
         <fi:items>
           <ft:widget id="field1"/>
+          <ft:widget id="field2"/>
+          <ft:widget id="field3"/>
         </fi:items>
       </fi:group>
       <input type="submit"/>

Modified: cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/library_form1.xml
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/library_form1.xml?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/library_form1.xml (original)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/library_form1.xml Wed Aug 24
16:45:25 2005
@@ -21,10 +21,16 @@
     <fd:class id="class1">
       <fd:widgets>
         <fd:field id="field1">
-          <fd:label>Field:</fd:label>
+          <fd:label>Field1:</fd:label>
           <fd:datatype base="string"/>
         </fd:field>
       </fd:widgets>
     </fd:class>
+    
+    <fd:field id="field2">
+      <fd:label>Field2:</fd:label>
+      <fd:datatype base="string"/>
+    </fd:field>
+    
   </fd:widgets>
 </fd:library>

Modified: cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap?rev=239967&r1=239966&r2=239967&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap (original)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap Wed Aug 24 16:45:25 2005
@@ -112,7 +112,7 @@
         <map:call resource="simple-page2html">
           <map:parameter name="file" value="resources/result_jx.xml"/>
         </map:call>
-        <map:serialize/>
+        <map:serialize type="xml"/>
       </map:match>
       
       <map:match pattern="resources/**">



Mime
View raw message