cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r289538 [4/8] - in /cocoon: blocks/forms/trunk/WEB-INF/xconf/ blocks/forms/trunk/conf/ blocks/forms/trunk/java/org/apache/cocoon/forms/ blocks/forms/trunk/java/org/apache/cocoon/forms/binding/ blocks/forms/trunk/java/org/apache/cocoon/forms...
Date Fri, 16 Sep 2005 13:48:35 GMT
Added: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java?rev=289538&view=auto
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java (added)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java Fri Sep 16 06:46:22 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005 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.apache.cocoon.forms.formmodel.library.Library;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.w3c.dom.Element;
+
+
+/**
+ * @version $Id$
+ */
+public class ImportDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
+
+	public static final String PREFIX_ATTRIBUTE = "prefix";
+	public static final String URI_ATTRIBUTE = "uri";
+	
+	/**
+	 * Imports a new library
+	 */
+	public WidgetDefinition buildWidgetDefinition(Element widgetElement)
+			throws Exception {
+		
+		if(this.context == null || this.context.getLocalLibrary() == null)
+			throw new Exception("Import statement seen and context is empty! (at "+DomHelper.getLocation(widgetElement)+")");
+			
+		Library lib = this.context.getLocalLibrary();
+		String prefix = DomHelper.getAttribute(widgetElement, PREFIX_ATTRIBUTE);
+		String uri = DomHelper.getAttribute(widgetElement, URI_ATTRIBUTE);
+		
+		if(!lib.includeAs(prefix,uri))
+			throw new Exception("Import statement did not succeed (probably used ':' in the prefix?)! (at "+DomHelper.getLocation(widgetElement)+")");
+		
+		return null;
+	}
+
+}

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java?rev=289538&view=auto
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java (added)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java Fri Sep 16 06:46:22 2005
@@ -0,0 +1,45 @@
+/*
+ * Copyright 1999-2005 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.apache.avalon.framework.CascadingException;
+
+/**
+ * @version $Id$
+ */
+public class IncompletenessException extends CascadingException {
+
+	private WidgetDefinition causingDefinition = null;
+
+	public IncompletenessException(String message, WidgetDefinition incomplete) {
+        super(message);
+        causingDefinition = incomplete;
+    }
+
+    public IncompletenessException(String message, WidgetDefinition incomplete , Exception e) {
+        super(message, e);
+        causingDefinition = incomplete;
+    }
+    
+    public String toString() {
+    	String msg = super.toString();
+    	
+    	if(causingDefinition!=null)
+    		msg += " (Caused by widget '"+causingDefinition.getId()+"', last modified at "+causingDefinition.getLocation()+")";
+    	
+    	return msg;
+    }
+}

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinition.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinition.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinition.java Fri Sep 16 06:46:22 2005
@@ -26,6 +26,16 @@
         return field;
     }
     
+    /**
+     * checks completeness of this definition
+     */
+    public void checkCompleteness() throws IncompletenessException {
+    	super.checkCompleteness();
+    	
+    	if (getSelectionList() == null)
+            throw new IncompletenessException("Error: multivaluefield always require a selectionlist!", this);
+    }
+    
 	public void setRequired(boolean required) {
 		throw new UnsupportedOperationException("The property 'required' is not available on widgets of type multivalue.");
 	}

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinitionBuilder.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinitionBuilder.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinitionBuilder.java Fri Sep 16 06:46:22 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
-import org.apache.cocoon.forms.util.DomHelper;
 import org.w3c.dom.Element;
 
 /**
@@ -28,9 +27,6 @@
     public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
         MultiValueFieldDefinition definition = new MultiValueFieldDefinition();
         setupDefinition(widgetElement, definition);
-        if (definition.getSelectionList() == null)
-            throw new Exception("Error: multivaluefield always require a selectionlist at " +
-                    DomHelper.getLocation(widgetElement));
         definition.makeImmutable();
         return definition;
     }

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/NewDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/NewDefinition.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/NewDefinition.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/NewDefinition.java Fri Sep 16 06:46:22 2005
@@ -40,6 +40,10 @@
     private ClassDefinition getClassDefinition() throws Exception {
         FormDefinition formDefinition = getFormDefinition();
         WidgetDefinition classDefinition = formDefinition.getWidgetDefinition(getId());
+        
+        if (classDefinition == null) // not found in local form, try library
+        	classDefinition = formDefinition.getLocalLibrary().getDefinition(getId());
+        
         if (classDefinition == null)
             throw new Exception("NewDefinition: Class with id \"" + getId() + "\" does not exist (" + getLocation() + ")");
         if (!(classDefinition instanceof ClassDefinition))
@@ -69,9 +73,12 @@
         parents.add(this);
         while (definitionsIt.hasNext()) {
             WidgetDefinition definition = (WidgetDefinition)definitionsIt.next();
+            // Recursively resolve containers
             if (definition instanceof ContainerDefinition) {
                 ((ContainerDefinition)definition).resolve(parents, parent);
             }
+            
+            // Add the current definition if it's not itself a "fd:new"
             if (definition instanceof NewDefinition) {
                 ((NewDefinition)definition).resolve(parents, parent);
             } else {

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java Fri Sep 16 06:46:22 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/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java Fri Sep 16 06:46:22 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/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java Fri Sep 16 06:46:22 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
-import org.apache.cocoon.forms.Constants;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.w3c.dom.Element;
 
@@ -24,7 +23,7 @@
  * 
  * @version $Id$
  */
-public final class RepeaterDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
+public final class RepeaterDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
     public WidgetDefinition buildWidgetDefinition(Element repeaterElement) throws Exception {
         
@@ -34,13 +33,7 @@
         super.setupDefinition(repeaterElement, repeaterDefinition);
         setDisplayData(repeaterElement, repeaterDefinition);
 
-        Element widgetsElement = DomHelper.getChildElement(repeaterElement, Constants.DEFINITION_NS, "widgets", true);
-        // All child elements of the widgets element are widgets
-        Element[] widgetElements = DomHelper.getChildElements(widgetsElement, Constants.DEFINITION_NS);
-        for (int i = 0; i < widgetElements.length; i++) {
-            WidgetDefinition widgetDefinition = buildAnotherWidgetDefinition(widgetElements[i]);
-            repeaterDefinition.addWidgetDefinition(widgetDefinition);
-        }
+        setupContainer(repeaterElement,"widgets",repeaterDefinition);
 
         repeaterDefinition.makeImmutable();
         return repeaterDefinition;

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/StructDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/StructDefinitionBuilder.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/StructDefinitionBuilder.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/StructDefinitionBuilder.java Fri Sep 16 06:46:22 2005
@@ -15,10 +15,8 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
-import org.w3c.dom.Element;
-import org.apache.cocoon.forms.Constants;
-import org.apache.cocoon.forms.util.DomHelper;
 import org.apache.cocoon.util.Deprecation;
+import org.w3c.dom.Element;
 
 /**
  * Builds {StructDefinition}s.
@@ -26,21 +24,14 @@
  * @deprecated replaced by {@link GroupDefinitionBuilder}
  * @version $Id$
  */
-public class StructDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
+public class StructDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
     public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
         StructDefinition definition = new StructDefinition();
         super.setupDefinition(element, definition);
         setDisplayData(element, definition);
 
-        Element widgetsElement = DomHelper.getChildElement(element, Constants.DEFINITION_NS, "widgets", true);
-        // All child elements of the widgets element are widgets
-        Element[] widgetElements = DomHelper.getChildElements(widgetsElement, Constants.DEFINITION_NS);
-        for (int i = 0; i < widgetElements.length; i++) {
-            Element widgetElement = widgetElements[i];
-            WidgetDefinition widgetDefinition = buildAnotherWidgetDefinition(widgetElement);
-            definition.addWidgetDefinition(widgetDefinition);
-        }
+        setupContainer(element,"widgets",definition);
 
         definition.makeImmutable();
         Deprecation.logger.info("Use of 'fd:struct' is deprecated. Use 'fd:group' instead, at " + definition.getLocation());

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java Fri Sep 16 06:46:22 2005
@@ -26,6 +26,22 @@
     
     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();
         this.validateForm = validateForm;

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java Fri Sep 16 06:46:22 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/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UnionDefinitionBuilder.java Fri Sep 16 06:46:22 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
-import org.apache.cocoon.forms.Constants;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.w3c.dom.Element;
 
@@ -24,7 +23,7 @@
  *
  * @version $Id$
  */
-public final class UnionDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
+public final class UnionDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
     public WidgetDefinition buildWidgetDefinition(Element element) throws Exception {
         UnionDefinition definition = new UnionDefinition();
@@ -32,14 +31,7 @@
         definition.setCaseWidgetId(DomHelper.getAttribute(element, "case", ""));
         setDisplayData(element, definition);
 
-        Element widgetsElement = DomHelper.getChildElement(element, Constants.DEFINITION_NS, "widgets", true);
-        // All child elements of the widgets element are widgets
-        Element[] widgetElements = DomHelper.getChildElements(widgetsElement, Constants.DEFINITION_NS);
-        for (int i = 0; i < widgetElements.length; i++) {
-            Element widgetElement = widgetElements[i];
-            WidgetDefinition widgetDefinition = buildAnotherWidgetDefinition(widgetElement);
-            definition.addWidgetDefinition(widgetDefinition);
-        }
+        setupContainer(element,"widgets",definition);
 
         definition.makeImmutable();
         return definition;

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Upload.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Upload.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Upload.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Upload.java Fri Sep 16 06:46:22 2005
@@ -23,11 +23,15 @@
 import org.apache.cocoon.forms.util.I18nMessage;
 import org.apache.cocoon.forms.validation.ValidationError;
 import org.apache.cocoon.forms.validation.ValidationErrorAware;
+
 import org.apache.cocoon.servlet.multipart.Part;
 import org.apache.cocoon.servlet.multipart.RejectedPart;
+
 import org.apache.cocoon.xml.AttributesImpl;
 import org.apache.cocoon.xml.XMLUtils;
+
 import org.apache.commons.lang.ObjectUtils;
+
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -50,7 +54,6 @@
     private Part part;
     private ValidationError validationError;
 
-
     public Upload(UploadDefinition uploadDefinition) {
         super(uploadDefinition);
         this.uploadDefinition = uploadDefinition;
@@ -61,7 +64,7 @@
     }
 
     public WidgetDefinition getDefinition() {
-        return uploadDefinition;
+        return this.uploadDefinition;
     }
 
     public Object getValue() {
@@ -134,25 +137,23 @@
         // No mime type restriction
         return true;
     }
-    
+
     /**
      * Check if the part is oversized, and if yes sets the validation error accordingly
      */
     private boolean validateOversize() {
-        if (this.part.isRejected()) {
-            // Set a validation error indicating the sizes in kbytes (rounded)
-            RejectedPart rjp = (RejectedPart)this.part;
-            int size = (rjp.getContentLength() + 512) / 1024;
-            int maxSize = (rjp.getMaxContentLength() + 512) / 1024;
-            setValidationError(new ValidationError(new I18nMessage(
-                    "upload.rejected",
-                    new String[] { String.valueOf(size), String.valueOf(maxSize) },
-                    Constants.I18N_CATALOGUE))
-            );
-            return false;
-        } else {
-            return false;
+        if (!this.part.isRejected()) {
+            return true; 
         }
+
+        // Set a validation error indicating the sizes in kbytes (rounded)
+        RejectedPart rjp = (RejectedPart)this.part;
+        int size = (rjp.getContentLength() + 512) / 1024;
+        int maxSize = (rjp.getMaxContentLength() + 512) / 1024;
+        String[] i18nParams = new String[] { String.valueOf(size), String.valueOf(maxSize) };
+        I18nMessage i18nMessage = new I18nMessage("upload.rejected", i18nParams, Constants.I18N_CATALOGUE);
+        setValidationError(new ValidationError(i18nMessage));
+        return false;
     }
 
     public boolean validate() {
@@ -163,13 +164,14 @@
 
         if (this.part == null) {
             if (this.uploadDefinition.isRequired()) {
-                setValidationError(new ValidationError(new I18nMessage("general.field-required", Constants.I18N_CATALOGUE)));
+                I18nMessage i18nMessage = new I18nMessage("general.field-required", Constants.I18N_CATALOGUE);
+                setValidationError(new ValidationError(i18nMessage));
             }
         } else if (validateOversize() && validateMimeType()) {
             super.validate();
         }
 
-        this.wasValid = validationError == null;
+        this.wasValid = this.validationError == null;
         return this.wasValid;
     }
 
@@ -178,7 +180,7 @@
      * {@link #validate()} method returned false.
      */
     public ValidationError getValidationError() {
-        return validationError;
+        return this.validationError;
     }
 
     /**
@@ -207,9 +209,9 @@
     public AttributesImpl getXMLElementAttributes() {
         AttributesImpl attrs = super.getXMLElementAttributes();
         attrs.addCDATAAttribute("id", getRequestParameterName());
-        attrs.addCDATAAttribute("required", String.valueOf(uploadDefinition.isRequired()));
-        if (uploadDefinition.getMimeTypes() != null) {
-            attrs.addCDATAAttribute("mime-types", uploadDefinition.getMimeTypes());
+        attrs.addCDATAAttribute("required", String.valueOf(this.uploadDefinition.isRequired()));
+        if (this.uploadDefinition.getMimeTypes() != null) {
+            attrs.addCDATAAttribute("mime-types", this.uploadDefinition.getMimeTypes());
         }
         return attrs;
     }
@@ -223,9 +225,9 @@
         }
 
         // validation message element: only present if the value is not valid
-        if (validationError != null) {
+        if (this.validationError != null) {
             contentHandler.startElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL, XMLUtils.EMPTY_ATTRIBUTES);
-            validationError.generateSaxFragment(contentHandler);
+            this.validationError.generateSaxFragment(contentHandler);
             contentHandler.endElement(Constants.INSTANCE_NS, VALIDATION_MSG_EL, Constants.INSTANCE_PREFIX_COLON + VALIDATION_MSG_EL);
         }
     }

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java Fri Sep 16 06:46:22 2005
@@ -26,9 +26,47 @@
     private boolean required;
     private String mimeTypes;
     
+    public UploadDefinition() {
+    	this.mimeTypes = null;
+    	this.required = false;
+    }
+    
     public UploadDefinition(boolean required, String mimeTypes) {
         this.required = required;
         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.substring(0); // deep copy
+    		
+    	} 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)
+    			mimeTypes = types;
+    		else {
+    			if(mimeTypes.length()>0)
+            		mimeTypes += ", ";
+            	mimeTypes += types;
+    		}
+    	}
+    }
+    
+    public void setRequired(boolean required) {
+    	this.required = required;
     }
 
     public Widget createInstance() {

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UploadDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UploadDefinitionBuilder.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UploadDefinitionBuilder.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/UploadDefinitionBuilder.java Fri Sep 16 06:46:22 2005
@@ -29,12 +29,16 @@
 
     public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
         String mimeTypes = DomHelper.getAttribute(widgetElement, "mime-types", null);
-        boolean required = DomHelper.getAttributeAsBoolean(widgetElement, "required", false);
         
-        UploadDefinition uploadDefinition = new UploadDefinition(required, mimeTypes);
+        UploadDefinition uploadDefinition = new UploadDefinition();
         super.setupDefinition(widgetElement, uploadDefinition);
 
         setDisplayData(widgetElement, uploadDefinition);
+        
+        if(widgetElement.hasAttribute("required"))
+            uploadDefinition.setRequired(DomHelper.getAttributeAsBoolean(widgetElement, "required", false));
+        
+        uploadDefinition.addMimeTypes(mimeTypes);
 
         uploadDefinition.makeImmutable();
         return uploadDefinition;

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Widget.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Widget.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Widget.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/Widget.java Fri Sep 16 06:46:22 2005
@@ -18,6 +18,8 @@
 import org.apache.cocoon.forms.FormContext;
 import org.apache.cocoon.forms.validation.WidgetValidator;
 import org.apache.cocoon.forms.event.WidgetEvent;
+import org.apache.cocoon.util.location.Locatable;
+import org.apache.cocoon.util.location.Location;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -51,7 +53,7 @@
  *
  * @version $Id$
  */
-public interface Widget {
+public interface Widget extends Locatable {
 
     /**
      * Widget-Separator used in path-like notations
@@ -69,7 +71,7 @@
     /**
      * @return  the source location of this widget.
      */
-    String getLocation();
+    Location getLocation();
 
     /**
      * @return the name of this widget.  This should never be <code>null</code>

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinition.java Fri Sep 16 06:46:22 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.cocoon.util.location.Locatable;
+import org.apache.cocoon.util.location.Location;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -26,8 +28,13 @@
  *
  * @version $Id$
  */
-public interface WidgetDefinition {
+public interface WidgetDefinition extends Locatable {
 
+	/**
+	 * Initializes this definition with values from the given other definition
+	 */
+	void initializeFrom(WidgetDefinition definition) throws Exception;
+	
     /**
      * Gets the {@link FormDefinition}.
      */
@@ -41,7 +48,7 @@
     /**
      * Gets source location of this widget definition.
      */
-    String getLocation();
+    Location getLocation();
 
     /**
      * Gets id of this widget definition.
@@ -65,6 +72,13 @@
      */
     boolean validate(Widget widget);
 
+    /**
+     * Checks whether this definition is complete since we are allowed to have partial
+     * definitions in libraries. Definitions need to be complete _before_ a call to
+     * createInstance() though.
+     */
+    void checkCompleteness() throws IncompletenessException;
+    
     /**
      * Creates and returns a widget based on this widget definition.
      */

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilder.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilder.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilder.java Fri Sep 16 06:46:22 2005
@@ -32,4 +32,5 @@
 
     WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception;
 
+    WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context) throws Exception;
 }

Added: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java?rev=289538&view=auto
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java (added)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java Fri Sep 16 06:46:22 2005
@@ -0,0 +1,54 @@
+/*
+ * 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.apache.cocoon.forms.formmodel.library.Library;
+
+/**
+ * Holds context information for the building phase.
+ * 
+ * @version $Id$
+ */
+public class WidgetDefinitionBuilderContext {
+
+	protected WidgetDefinition superDefinition = null;
+	protected Library localLibrary = null;
+	
+	public WidgetDefinitionBuilderContext() {
+		this.superDefinition = null;
+		this.localLibrary = null;
+	}
+	
+	public WidgetDefinitionBuilderContext(WidgetDefinitionBuilderContext other) {
+		this.superDefinition = other.superDefinition;
+		this.localLibrary = other.localLibrary;
+	}
+	
+	public WidgetDefinition getSuperDefinition() {
+		return superDefinition;
+	}
+	public void setSuperDefinition(WidgetDefinition def) {
+		superDefinition = def;
+	}
+	
+	public Library getLocalLibrary() {
+		return localLibrary;
+	}
+	public void setLocalLibrary(Library lib) {
+		localLibrary = lib;
+	}
+	
+}

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java Fri Sep 16 06:46:22 2005
@@ -1,6 +1,6 @@
 /*
  * 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
@@ -22,6 +22,8 @@
 import java.util.ListIterator;
 import java.util.Map;
 
+import org.apache.cocoon.util.location.Location;
+
 // TODO: Refine and i18n the exception messages.
 /**
  * Helper class for the Definition implementation of widgets containing
@@ -34,7 +36,7 @@
     private List widgetDefinitions = new ArrayList();
     private Map widgetDefinitionsById = new HashMap();
     private WidgetDefinition containerDefinition;
-    private boolean resolving;
+    private boolean wasHere;
     private ListIterator definitionsIt = widgetDefinitions.listIterator();
 
     /**
@@ -42,7 +44,11 @@
      */
     public WidgetDefinitionList(WidgetDefinition definition) {
         this.containerDefinition = definition;
-        resolving = false;
+        wasHere = false;
+    }
+    
+    public int size() {
+    	return widgetDefinitions.size();
     }
 
     public void addWidgetDefinition(WidgetDefinition widgetDefinition) throws DuplicateIdException {
@@ -50,9 +56,9 @@
         // Do not add NewDefinition id's hash.
         if (!(widgetDefinition instanceof NewDefinition)) {
             if (widgetDefinitionsById.containsKey(id)) {
-                String duplicateLocation = widgetDefinition.getLocation();
-                String containerLocation = containerDefinition.getLocation();
-                String firstLocation = getWidgetDefinition(id).getLocation();
+                Location duplicateLocation = widgetDefinition.getLocation();
+                Location containerLocation = containerDefinition.getLocation();
+                Location firstLocation = getWidgetDefinition(id).getLocation();
                 throw new DuplicateIdException(
                     "Duplicate widget id \"" + id + "\" detected at " + duplicateLocation + ".\n" +
                     "Container widget \"" + containerDefinition.getId() + "\" at " + containerLocation + "\n" +
@@ -75,13 +81,9 @@
         return (WidgetDefinition)widgetDefinitionsById.get(id);
     }
 
-    public boolean isResolving() {
-        return resolving;
-    }
-
     public void resolve(List parents, WidgetDefinition parent) throws Exception {
-        if (!resolving) {
-            resolving = true;
+        if (!wasHere) {
+            wasHere = true;
             this.definitionsIt = widgetDefinitions.listIterator();
             parents.add(containerDefinition);
             while (this.definitionsIt.hasNext()) {
@@ -99,24 +101,22 @@
                 }
             }
             parents.remove(parents.size()-1);
-            resolving = false;
+            wasHere = false;
         } else {
             // Non-terminating recursion detection
-            if (resolving == true) {
-               // Search up parent list in hopes of finding a "Union" or "Repeater" before finding previous "New" for this "Class".
-                ListIterator parentsIt = parents.listIterator(parents.size());
-                while(parentsIt.hasPrevious()) {
-                    WidgetDefinition widgetDefinition = (WidgetDefinition)parentsIt.previous();
-                    if (widgetDefinition instanceof UnionDefinition) break;
-                    if (widgetDefinition instanceof RepeaterDefinition) break;
-                    if (widgetDefinition == containerDefinition) {
-                        String location = containerDefinition.getLocation();
-                        if (parent instanceof FormDefinition) {
-                            throw new Exception("Container: Non-terminating recursion detected in form definition (" + location + ")");
-                        } 
-                        throw new Exception("Container: Non-terminating recursion detected in widget definition: "
-                            + parent.getId() + " (" + location + ")");
-                    }
+            // Search up parent list in hopes of finding a "Union" or "Repeater" before finding previous "New" for this "Class".
+            ListIterator parentsIt = parents.listIterator(parents.size());
+            while(parentsIt.hasPrevious()) {
+                WidgetDefinition widgetDefinition = (WidgetDefinition)parentsIt.previous();
+                if (widgetDefinition instanceof UnionDefinition) break;
+                if (widgetDefinition instanceof RepeaterDefinition) break;
+                if (widgetDefinition == containerDefinition) {
+                    Location location = containerDefinition.getLocation();
+                    if (parent instanceof FormDefinition) {
+                        throw new Exception("Container: Non-terminating recursion detected in form definition (" + location + ")");
+                    } 
+                    throw new Exception("Container: Non-terminating recursion detected in widget definition: "
+                        + parent.getId() + " (" + location + ")");
                 }
             }
         }
@@ -140,6 +140,23 @@
             Widget widget = widgetDefinition.createInstance();
             if (widget != null)
                 ((ContainerWidget)parent).addChild(widget);
+        }
+    }
+
+    public void checkCompleteness() throws IncompletenessException {
+        if (!wasHere) {
+            wasHere = true;
+// FIXME: is it legal to have no widgets in a container? There are some cases of this in Swan
+//            if(size() == 0)
+//                throw new IncompletenessException(this.containerDefinition.getClass().getName() + 
+//                        " requires at least one child widget!", this.containerDefinition);
+            
+            // now check children's completeness
+            Iterator it = widgetDefinitions.iterator();
+            while(it.hasNext()) {
+                ((WidgetDefinition)it.next()).checkCompleteness();
+            }
+            wasHere = false;
         }
     }
 }

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetList.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetList.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetList.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/WidgetList.java Fri Sep 16 06:46:22 2005
@@ -43,7 +43,7 @@
      * List of the contained widgets.
      * This maintains the original order of the widgets to garantee order of
      * validation and generation of SAXFragments
-     */ 
+     */
     private List widgets;
     
     /** 

Added: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/Library.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/Library.java?rev=289538&view=auto
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/Library.java (added)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/Library.java Fri Sep 16 06:46:22 2005
@@ -0,0 +1,221 @@
+/*
+ * Copyright 1999-2005 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.library;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.avalon.framework.CascadingException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.cocoon.forms.Constants;
+import org.apache.cocoon.forms.formmodel.WidgetDefinition;
+import org.apache.cocoon.forms.formmodel.WidgetDefinitionBuilder;
+import org.apache.cocoon.forms.formmodel.WidgetDefinitionBuilderContext;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.cocoon.util.location.LocationAttributes;
+
+import org.w3c.dom.Element;
+
+/**
+ * @version $Id$
+ */
+public class Library {
+
+	public static final String SEPARATOR = ":";
+	
+	
+	// managed instances
+	protected ServiceSelector widgetDefinitionBuilderSelector;
+	
+	// own references
+	protected LibraryManager manager = null;
+	
+	// own instances
+	protected Map definitions = new HashMap();
+	protected Map inclusions = new HashMap();
+	
+	// shared object with dependencies
+	protected Object shared = new Object();
+	
+	protected String sourceURI = null;
+	protected WidgetDefinitionBuilderContext context;
+	
+	public Library(LibraryManager lm) {
+		manager = lm;
+		context = new WidgetDefinitionBuilderContext();
+		context.setLocalLibrary(this);
+	}
+	
+	public void setSourceURI(String uri) {
+		sourceURI = uri;
+	}
+	public String getSourceURI() {
+		return sourceURI;
+	}
+	
+	public void setWidgetDefinitionBuilderSelector(ServiceSelector selector) {
+		this.widgetDefinitionBuilderSelector = selector;
+	}
+	
+	public boolean dependenciesHaveChanged() throws Exception {
+		
+		Iterator it = this.inclusions.values().iterator();
+		while(it.hasNext()) {
+			Dependency dep = (Dependency)it.next();
+			if(!dep.isValid())
+				return true;
+		}
+		
+		return false;
+	}
+	
+	/**
+	 * "Registers" a library to be referenced later under a certain key or prefix.
+	 * Definitions will be accessible locally through prefixing: "prefix:definitionid"
+	 * 
+	 * @param key the key 
+	 * @param librarysource the source of the library to be know as "key"
+	 * @return true if there was no such key used before, false otherwise
+	 */
+	public boolean includeAs(String key, String librarysource)
+		throws LibraryException 
+	{
+		try {
+			// library keys may not contain ":"!
+			if( (!inclusions.containsKey(key) || key.indexOf(SEPARATOR)>-1) 
+					&& manager.getLibrary(librarysource, sourceURI)!=null) {
+				inclusions.put(key,new Dependency(librarysource));
+				return true;
+			}
+			return false;
+		} catch(Exception e) {
+			throw new LibraryException("Could not include library '"+librarysource+"'",e);
+		}
+		
+	}
+	
+	public WidgetDefinition getDefinition(String key) throws LibraryException {
+		
+		String librarykey = null;
+		String definitionkey = key;
+		
+		if(key.indexOf(":")>-1) {
+			String[] parts = key.split(SEPARATOR);
+			librarykey = parts[0];
+			definitionkey = parts[1];
+			for(int i=2; i<parts.length; i++) {
+				definitionkey += SEPARATOR+parts[i];
+			}
+		}
+		
+		if(librarykey!=null) {
+			if(inclusions.containsKey(librarykey)) {
+				try {
+					return manager.getLibrary(((Dependency)inclusions.get(librarykey)).dependencySourceURI, sourceURI).getDefinition(definitionkey);
+				} catch(Exception e) {
+					throw new LibraryException("Couldn't get Library key='"+librarykey+"' source='"+inclusions.get(librarykey)+"",e);
+				}
+			} else {
+				throw new LibraryException("Library '"+librarykey+"' does not exist! (lookup: '"+key+"')");
+			}
+		} else {
+			return (WidgetDefinition)definitions.get(definitionkey);
+		}
+	}
+	
+	public void buildLibrary(Element libraryElement) throws Exception {
+		sourceURI = LocationAttributes.getURI(libraryElement);
+		Element widgetsElement = DomHelper.getChildElement(libraryElement, Constants.DEFINITION_NS, "widgets", true);
+        // All child elements of the widgets element are widgets
+        Element[] widgetElements = DomHelper.getChildElements(widgetsElement, Constants.DEFINITION_NS);
+        for (int i = 0; i < widgetElements.length; i++) {
+            Element widgetElement = widgetElements[i];
+            WidgetDefinition widgetDefinition = buildWidgetDefinition(widgetElement);
+            addDefinition(widgetDefinition);
+        }
+	}
+	
+	public void addDefinition(WidgetDefinition definition) throws LibraryException {
+		if(definition == null)
+			return;
+		
+		if(definitions.containsKey(definition.getId()))
+			throw new LibraryException("Library already contains a widget with this ID!");
+		
+		definitions.put(definition.getId(),definition);
+		manager.debug(this+": Put definition with id: "+definition.getId());
+	}
+	
+	protected WidgetDefinition buildWidgetDefinition(Element widgetDefinition) throws Exception {
+        String widgetName = widgetDefinition.getLocalName();
+        WidgetDefinitionBuilder builder = null;
+        try {
+            builder = (WidgetDefinitionBuilder)widgetDefinitionBuilderSelector.select(widgetName);
+        } catch (ServiceException e) {
+            throw new CascadingException("Unknown kind of widget '" + widgetName + "' at " +
+                                         DomHelper.getLocation(widgetDefinition), e);
+        }
+        
+        context.setSuperDefinition(null);
+        String extend = DomHelper.getAttribute(widgetDefinition, "extends", null);
+        
+        if (extend != null)
+            context.setSuperDefinition(getDefinition(extend));
+        
+        
+        return builder.buildWidgetDefinition(widgetDefinition,context);
+    }
+	
+	
+	/**
+	 * Encapsulates a uri to designate an import plus a timestamp so previously reloaded 
+	 * 
+	 * @author Max Pfingsthorn (mpfingsthorn@hippo.nl)
+	 *
+	 */
+	public class Dependency {
+		
+		private String dependencySourceURI;
+		private Object shared;
+		
+		public Dependency(String dependencySourceURI) throws Exception {
+			this.dependencySourceURI = dependencySourceURI;
+			
+			Library lib = manager.getLibrary(this.dependencySourceURI,sourceURI);
+			this.shared = lib.shared;
+		}
+		
+		public boolean isValid() throws LibraryException {
+			try {
+				
+				if(manager.libraryInCache(dependencySourceURI,sourceURI)) {
+					Library lib = manager.getLibrary(dependencySourceURI,sourceURI);
+					
+					if(this.shared == lib.shared)
+						return true;
+				}
+				
+				return false;
+			} catch(Exception forward) {
+				throw new LibraryException("Exception occured while checking dependency validity!",forward);
+			}
+			
+		}
+	}
+	
+}

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/Library.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/Library.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryException.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryException.java?rev=289538&view=auto
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryException.java (added)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryException.java Fri Sep 16 06:46:22 2005
@@ -0,0 +1,33 @@
+/*
+ * Copyright 1999-2005 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.library;
+
+import org.apache.avalon.framework.CascadingException;
+
+/**
+ * This exception is thrown when something specific to the library system goes wrong.
+ * 
+ * @version $Id$
+ */
+public class LibraryException extends CascadingException {
+    public LibraryException(String message) {
+        super(message);
+    }
+
+    public LibraryException(String message, Exception e) {
+        super(message, e);
+    }
+}

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryException.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java?rev=289538&view=auto
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java (added)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java Fri Sep 16 06:46:22 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 1999-2005 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.library;
+
+
+
+/**
+ * The work interface for the LibraryManager, the class that
+ * manages all used library definitions so they can be shared between
+ * forms.
+ * 
+ * @version $Id$
+ *
+ */
+public interface LibraryManager {
+
+	String ROLE = LibraryManager.class.getName();
+	
+	Library getLibrary(String librarysource) throws Exception;
+	Library getLibrary(String librarysource, String relative) throws Exception;
+	Library getNewLibrary();
+	
+	boolean libraryInCache(String librarysource) throws Exception;
+	boolean libraryInCache(String librarysource, String relative) throws Exception;
+	
+	void debug(String msg);
+}

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java?rev=289538&view=auto
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java (added)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java Fri Sep 16 06:46:22 2005
@@ -0,0 +1,196 @@
+/*
+ * Copyright 1999-2005 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.library;
+
+import org.apache.avalon.framework.CascadingException;
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.forms.CacheManager;
+import org.apache.cocoon.forms.formmodel.WidgetDefinitionBuilder;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+
+/**
+ * @version $Id$
+ *
+ */
+public class LibraryManagerImpl extends AbstractLogEnabled implements LibraryManager, ThreadSafe, Serviceable,
+Configurable, Initializable, Disposable {
+
+	protected static final String PREFIX = "CocoonFormLibrary:";
+	
+	private ServiceManager serviceManager;
+    private Configuration configuration;
+    private CacheManager cacheManager;
+    
+    private ServiceSelector widgetDefinitionBuilderSelector;
+
+    public void configure(Configuration configuration) throws ConfigurationException {
+        this.configuration = configuration;
+        getLogger().debug("Gotten a config: top level element: "+this.configuration);
+    }
+
+    public void service(ServiceManager serviceManager) throws ServiceException {
+        this.serviceManager = serviceManager;
+        this.cacheManager = (CacheManager)serviceManager.lookup(CacheManager.ROLE);
+    }
+    
+    public void initialize() throws Exception {
+    	this.widgetDefinitionBuilderSelector = (ServiceSelector) serviceManager.lookup(WidgetDefinitionBuilder.class.getName() + "Selector");
+    	
+        // read config to "preload" libraries
+    }
+    
+    public boolean libraryInCache(String librarysource) throws Exception {
+    	return libraryInCache(librarysource,null);
+    }
+    
+    public boolean libraryInCache(String librarysource, String relative) throws Exception {
+    	SourceResolver sourceResolver = null;
+        Source source = null;
+        
+        if(getLogger().isDebugEnabled())
+        	getLogger().debug("Checking if library is in cache: '"+librarysource+"' relative to '"+relative+"'");
+
+        Library lib = null;
+        boolean result = false;
+        
+        try {
+            sourceResolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
+            source = sourceResolver.resolveURI(librarysource, relative, null);
+            
+            lib = (Library)this.cacheManager.get(source, PREFIX);
+            
+            if( lib != null && lib.dependenciesHaveChanged() ) {
+            	result = false;
+            	this.cacheManager.set(null,source,PREFIX); //evict?
+            }
+            else if( lib == null )
+            	result = false;
+            else
+            	result = true;
+        } catch(Exception e) {
+        	if(getLogger().isErrorEnabled())
+            	getLogger().error("Problem getting library '"+librarysource+"' relative to '"+relative+"'!",e);
+        	throw e;
+        } finally {
+            if (source != null)
+                sourceResolver.release(source);
+            if (sourceResolver != null)
+            	serviceManager.release(sourceResolver);
+        }
+
+        if(getLogger().isDebugEnabled()) {
+        	if(result)
+        		getLogger().debug("Library IS in cache : '"+librarysource+"' relative to '"+relative+"'");
+        	else
+        		getLogger().debug("Library IS NOT in cache : '"+librarysource+"' relative to '"+relative+"'");
+        }
+        
+        return result;
+    }
+    
+    public Library getLibrary(String librarysource) throws Exception {
+    	return getLibrary(librarysource,null);
+    }
+    
+	public Library getLibrary(String librarysource, String relative) throws Exception {
+		SourceResolver sourceResolver = null;
+        Source source = null;
+        Document libraryDocument = null;
+
+        Library lib = null;
+        
+        if(getLogger().isDebugEnabled())
+        	getLogger().debug("Getting library instance: '"+librarysource+"' relative to '"+relative+"'");
+        
+        try {
+            sourceResolver = (SourceResolver)serviceManager.lookup(SourceResolver.ROLE);
+            source = sourceResolver.resolveURI(librarysource, relative, null);
+            
+            lib = (Library)this.cacheManager.get(source, PREFIX);
+            
+            if( lib != null && lib.dependenciesHaveChanged() ) {
+            	if(getLogger().isDebugEnabled())
+                	getLogger().debug("Library dependencies changed, invalidating!");
+            	
+            	lib = null;
+            }
+            
+            if( lib == null ) {
+            	if(getLogger().isDebugEnabled())
+                	getLogger().debug("Library not in cache, creating!");
+            	
+            	try {
+                    InputSource inputSource = new InputSource(source.getInputStream());
+                    inputSource.setSystemId(source.getURI());
+                    libraryDocument = DomHelper.parse(inputSource, this.serviceManager);
+                    
+                    lib = getNewLibrary();
+                    lib.buildLibrary(libraryDocument.getDocumentElement());
+                    
+                    this.cacheManager.set(lib,source,PREFIX);
+                    
+                } catch (Exception e) {
+                    throw new CascadingException("Could not parse form definition from " +
+                                                 source.getURI(), e);
+                }
+            }
+        } finally {
+            if (source != null)
+                sourceResolver.release(source);
+            if (sourceResolver != null)
+            	serviceManager.release(sourceResolver);
+        }
+
+        return lib;
+	}
+	
+	public Library getNewLibrary() {
+		Library lib = new Library(this);
+        lib.setWidgetDefinitionBuilderSelector(this.widgetDefinitionBuilderSelector);
+        
+        if(getLogger().isDebugEnabled())
+        	getLogger().debug("Created new library! "+lib);
+        
+        return lib;
+	}
+
+	public void dispose() {
+		this.serviceManager.release(this.cacheManager);
+	    this.cacheManager = null;
+	    this.serviceManager = null;
+	}
+	
+	public void debug(String msg) {
+		if(getLogger().isDebugEnabled()) {
+			getLogger().debug(msg);
+		}
+	}
+	
+}

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java Fri Sep 16 06:46:22 2005
@@ -300,7 +300,9 @@
     }
 
     public void generateRepeaterWidgetLabel(Widget widget, String id, String widgetId) throws SAXException {
-        getRepeater(widget, id).generateWidgetLabel(widgetId, this.cocoonConsumer);
+        // Widget labels are allowed either inside or outside of <ft:repeater>
+        Repeater repeater = widget instanceof Repeater ? (Repeater)widget : getRepeater(widget, id);
+        repeater.generateWidgetLabel(widgetId, this.cocoonConsumer);
     }
 
     public void generateRepeaterSize(Widget widget, String id) throws SAXException {

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/jx-macros.xml Fri Sep 16 06:46:22 2005
@@ -213,6 +213,7 @@
       <jx:parameter name="id"/>
       <jx:if test="${cformsHelper.pushRepeater(id)}">
         <jx:set var="repeater" value="${cformsHelper.peekWidget()}"/>
+        <jx:set var="widget" value="${cformsHelper.peekWidget()}"/>
         <jx:evalBody/>
         <jx:set var="cformsDummy" value="${cformsHelper.popWidget()}"/>
       </jx:if>

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-calendar-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-calendar-styling.xsl?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-calendar-styling.xsl (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/resources/forms-calendar-styling.xsl Fri Sep 16 06:46:22 2005
@@ -17,6 +17,7 @@
 <xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+                xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
                 exclude-result-prefixes="fi">
   <!--+
       | This stylesheet is designed to be included by 'forms-advanced-styling.xsl'.
@@ -71,14 +72,12 @@
       <!-- calendar popup -->
       <xsl:choose>
         <xsl:when test="@state = 'disabled'">
-          <!-- TODO: i18n key for @alt -->
-          <img src="{$resources-uri}/img/cal.gif" alt="Calendar"/>
+          <img src="{$resources-uri}/img/cal.gif" alt="forms:calendar.alt" i18n:attr="alt"/>
         </xsl:when>
         <xsl:otherwise>
           <a href="#" name="{$id}" id="{$id}"
              onclick="forms_calendar.select(forms_getForm(this)['{@id}'],'{$id}','{$format}'); return false;">
-            <!-- TODO: i18n key for @alt -->
-            <img src="{$resources-uri}/img/cal.gif" alt="Calendar"/>
+            <img src="{$resources-uri}/img/cal.gif" alt="forms:calendar.alt" i18n:attr="alt"/>
           </a>
         </xsl:otherwise>
       </xsl:choose>

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/EffectPipe.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/EffectPipe.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/EffectPipe.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/EffectPipe.java Fri Sep 16 06:46:22 2005
@@ -175,88 +175,88 @@
      */
     protected class BufferHandler extends NullHandler {
         public Handler startDocument() throws SAXException {
-            buffer.startDocument();
+            if (buffer != null) buffer.startDocument();
             return this;
         }
 
         public void setDocumentLocator(Locator paramLocator) {
             locator = new LocatorImpl(paramLocator);
-            buffer.setDocumentLocator(paramLocator);
+            if (buffer != null) buffer.setDocumentLocator(paramLocator);
         }
 
         public void endDocument() throws SAXException {
-            buffer.endDocument();
+            if (buffer != null) buffer.endDocument();
         }
 
         public void startPrefixMapping(String prefix, String uri) throws SAXException {
-            buffer.startPrefixMapping(prefix, uri);
+            if (buffer != null) buffer.startPrefixMapping(prefix, uri);
         }
 
         public void endPrefixMapping(String prefix) throws SAXException {
-            buffer.endPrefixMapping(prefix);
+            if (buffer != null) buffer.endPrefixMapping(prefix);
         }
 
         public Handler startElement(String uri, String loc, String raw, Attributes attrs) throws SAXException {
-            buffer.startElement(uri, loc, raw, attrs);
+            if (buffer != null) buffer.startElement(uri, loc, raw, attrs);
             return this;
         }
 
         public void endElement(String uri, String loc, String raw) throws SAXException {
-            buffer.endElement(uri, loc, raw);
+            if (buffer != null) buffer.endElement(uri, loc, raw);
         }
 
         public Handler characters(char ch[], int start, int length) throws SAXException {
-            buffer.characters(ch, start, length);
+            if (buffer != null) buffer.characters(ch, start, length);
             return this;
         }
 
         public Handler ignorableWhitespace(char ch[], int start, int length) throws SAXException {
-            buffer.ignorableWhitespace(ch, start, length);
+            if (buffer != null) buffer.ignorableWhitespace(ch, start, length);
             return this;
         }
 
         public Handler processingInstruction(String target, String data) throws SAXException {
-            buffer.processingInstruction(target, data);
+            if (buffer != null) buffer.processingInstruction(target, data);
             return this;
         }
 
         public Handler skippedEntity(String name) throws SAXException {
-            buffer.skippedEntity(name);
+            if (buffer != null) buffer.skippedEntity(name);
             return this;
         }
 
         public Handler startDTD(String name, String publicId, String systemId) throws SAXException {
-            buffer.startDTD(name, publicId, systemId);
+            if (buffer != null) buffer.startDTD(name, publicId, systemId);
             return this;
         }
 
         public Handler endDTD() throws SAXException {
-            buffer.endDTD();
+            if (buffer != null) buffer.endDTD();
             return this;
         }
 
         public Handler startEntity(String name) throws SAXException {
-            buffer.startEntity(name);
+            if (buffer != null) buffer.startEntity(name);
             return this;
         }
 
         public Handler endEntity(String name) throws SAXException {
-            buffer.endEntity(name);
+            if (buffer != null) buffer.endEntity(name);
             return this;
         }
 
         public Handler startCDATA() throws SAXException {
-            buffer.startCDATA();
+            if (buffer != null) buffer.startCDATA();
             return this;
         }
 
         public Handler endCDATA() throws SAXException {
-            buffer.endCDATA();
+            if (buffer != null) buffer.endCDATA();
             return this;
         }
 
         public Handler comment(char c[], int start, int len) throws SAXException {
-            buffer.comment(c, start, len);
+            if (buffer != null) buffer.comment(c, start, len);
             return this;
         }
     }

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/FormsPipelineConfig.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/FormsPipelineConfig.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/FormsPipelineConfig.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/transformation/FormsPipelineConfig.java Fri Sep 16 06:46:22 2005
@@ -24,6 +24,7 @@
 import org.apache.cocoon.environment.Session;
 import org.apache.cocoon.forms.formmodel.Form;
 import org.apache.cocoon.i18n.I18nUtils;
+import org.apache.cocoon.util.Deprecation;
 
 import org.apache.commons.jxpath.JXPathContext;
 import org.apache.commons.jxpath.JXPathException;
@@ -34,7 +35,9 @@
 
 import java.io.IOException;
 import java.io.StringReader;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
@@ -120,8 +123,18 @@
         }
         cocoonOM.put("parameters", parameters);
 
-        Variables vars = jxpc.getVariables();
+        FormsVariables vars = new FormsVariables();
         vars.declareVariable("cocoon", cocoonOM);
+        // These four are deprecated!
+        vars.declareVariable("continuation", wk);
+        vars.declareVariable("request", request);
+        vars.declareVariable("session", session);
+        vars.declareVariable("parameters", parameters);
+        vars.addDeprecatedVariable("continuation");
+        vars.addDeprecatedVariable("request");
+        vars.addDeprecatedVariable("session");
+        vars.addDeprecatedVariable("parameters");
+        jxpc.setVariables(vars);
 
         Locale localeParameter = null;
         String localeStr = parameters.getParameter("locale", null);
@@ -326,6 +339,50 @@
         }
         if (getFormMethod() != null){
             attrs.addAttribute("", "method", "method", "CDATA", getFormMethod());
+        }
+    }
+
+    public static final class FormsVariables implements Variables {
+
+        final Map vars = new HashMap();
+        final List deprecatedNames = new ArrayList();
+
+        public void addDeprecatedVariable(String name) {
+            this.deprecatedNames.add(name);
+        }
+
+        /* (non-Javadoc)
+         * @see org.apache.commons.jxpath.Variables#declareVariable(java.lang.String, java.lang.Object)
+         */
+        public void declareVariable(String name, Object value) {
+            this.vars.put(name, value);
+        }
+
+        /* (non-Javadoc)
+         * @see org.apache.commons.jxpath.Variables#getVariable(java.lang.String)
+         */
+        public Object getVariable(String name) {
+            Object value = this.vars.get(name);
+            if ( deprecatedNames.contains(name) ) {
+                Deprecation.logger.warn("CForms: usage of the variable '" + name + "' is deprecated."+
+                                        "Please use 'cocoon/" + name + "' instead. The usage of just '"+
+                                        name+"' will be removed in Cocoon 2.2.");
+            }
+            return value;
+        }
+
+        /* (non-Javadoc)
+         * @see org.apache.commons.jxpath.Variables#isDeclaredVariable(java.lang.String)
+         */
+        public boolean isDeclaredVariable(String name) {
+            return this.vars.containsKey(name);
+        }
+
+        /* (non-Javadoc)
+         * @see org.apache.commons.jxpath.Variables#undeclareVariable(java.lang.String)
+         */
+        public void undeclareVariable(String name) {
+            this.vars.remove(name);
         }
     }
 }

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/util/DomHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/util/DomHelper.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/util/DomHelper.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/util/DomHelper.java Fri Sep 16 06:46:22 2005
@@ -25,6 +25,7 @@
 
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.util.location.LocationAttributes;
 import org.apache.cocoon.xml.SaxBuffer;
 import org.apache.cocoon.xml.dom.DOMBuilder;
@@ -62,6 +63,10 @@
 
     public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
 
+    public static Location getLocationObject(Element element) {
+        return LocationAttributes.getLocation(element);
+    }
+
     /**
      * Retrieves the location of an element node in the source file from which
      * the Document was created. This will only work for Document's created
@@ -178,7 +183,7 @@
      * element has no such attribute.
      */
     public static String getAttribute(Element element, String attributeName, 
-            String defaultValue) throws Exception {
+            String defaultValue) {
         String attrValue = element.getAttribute(attributeName);
         if (attrValue.equals("")) {
             return defaultValue;

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/util/JavaScriptHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/util/JavaScriptHelper.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/util/JavaScriptHelper.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/util/JavaScriptHelper.java Fri Sep 16 06:46:22 2005
@@ -23,7 +23,6 @@
 import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.cocoon.components.flow.FlowHelper;
 import org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptFlowHelper;
-import org.apache.cocoon.environment.TemplateObjectModelHelper;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.Function;
 import org.mozilla.javascript.JavaScriptException;
@@ -39,6 +38,12 @@
  * @version $Id$
  */
 public class JavaScriptHelper {
+
+    /**
+     * A shared root scope, avoiding to recreate a new one each time.
+     */
+    private static Scriptable _rootScope = null;
+
     /**
      * Build a script with the content of a DOM element.
      * 
@@ -111,7 +116,20 @@
      * @return an appropriate root scope
      */
     public static Scriptable getRootScope() {
-        return TemplateObjectModelHelper.getScope();
+        // FIXME: TemplateOMH should be used in 2.2
+        //return TemplateObjectModelHelper.getScope();
+        
+        
+        if (_rootScope == null) {
+            // Create it if never used up to now
+            Context ctx = Context.enter();
+            try {
+                _rootScope = ctx.initStandardObjects(null);
+            } finally {
+                Context.exit();
+            }
+        }
+        return _rootScope;
     }
 
     /**

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/validation/WidgetValidatorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/validation/WidgetValidatorBuilder.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/validation/WidgetValidatorBuilder.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/validation/WidgetValidatorBuilder.java Fri Sep 16 06:46:22 2005
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -19,14 +19,14 @@
 import org.w3c.dom.Element;
 
 /**
- * 
+ *
  * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
  * @version $Id$
  */
 public interface WidgetValidatorBuilder {
-    
+
     String ROLE = WidgetValidatorBuilder.class.getName();
-    
+
     /**
      * Builds a {@link WidgetValidator} for a particular widget definition.
      * 

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidatorBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidatorBuilder.java?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidatorBuilder.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/validation/impl/JavaScriptValidatorBuilder.java Fri Sep 16 06:46:22 2005
@@ -35,7 +35,7 @@
  */
 public class JavaScriptValidatorBuilder 
     implements WidgetValidatorBuilder, Contextualizable, ThreadSafe {
-    
+
     private Context avalonContext;
     
     private static final String[] ARG_NAMES = {"widget"};

Modified: cocoon/blocks/forms/trunk/samples/captcha/forms/captcha.tpl.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/samples/captcha/forms/captcha.tpl.xml?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/samples/captcha/forms/captcha.tpl.xml (original)
+++ cocoon/blocks/forms/trunk/samples/captcha/forms/captcha.tpl.xml Fri Sep 16 06:46:22 2005
@@ -18,6 +18,7 @@
       xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
       xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
 
+  <h4 class="samplesGroup">CAPTCHA widget</h4>
   <title>CAPTCHA validation sample form</title>
   <content>
     <p>This is a demonstration of <a href="http://www.captcha.net/">CAPTCHA</a>
@@ -29,7 +30,11 @@
           <ft:widget id="f1"/>
         </fi:items>
       </fi:group>
+      After entering the string, press Enter.
     </ft:form-template>
+    <p>
+      <a href="../">Back to Forms samples</a>
+    </p>
   </content>
 </page>
 

Modified: cocoon/blocks/forms/trunk/samples/captcha/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/samples/captcha/sitemap.xmap?rev=289538&r1=289537&r2=289538&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/samples/captcha/sitemap.xmap (original)
+++ cocoon/blocks/forms/trunk/samples/captcha/sitemap.xmap Fri Sep 16 06:46:22 2005
@@ -88,6 +88,8 @@
        <map:transform src="../resources/forms-samples-styling.xsl">
          <map:parameter name="resources-uri" value="../resources"/>
        </map:transform>
+       <map:transform type="i18n">
+       </map:transform>
        <map:serialize/>
      </map:match>
 



Mime
View raw message