cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpfingsth...@apache.org
Subject svn commit: r239913 - in /cocoon/gsoc/mpfingsthorn/forms: ./ WEB-INF/xconf/ java/org/apache/cocoon/forms/ java/org/apache/cocoon/forms/formmodel/ java/org/apache/cocoon/forms/formmodel/library/ samples/ samples/library/ samples/library/flow/ samples/li...
Date Wed, 24 Aug 2005 20:09:36 GMT
Author: mpfingsthorn
Date: Wed Aug 24 13:08:52 2005
New Revision: 239913

URL: http://svn.apache.org/viewcvs?rev=239913&view=rev
Log:
first sample working with import!

Added:
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java
    cocoon/gsoc/mpfingsthorn/forms/samples/library/
    cocoon/gsoc/mpfingsthorn/forms/samples/library/flow/
    cocoon/gsoc/mpfingsthorn/forms/samples/library/flow/library.js
    cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/
    cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_binding.xml   (with props)
    cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_data.xml   (with props)
    cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_model.xml   (with props)
    cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_template.xml   (with props)
    cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/
    cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/library_form1.xml   (with props)
    cocoon/gsoc/mpfingsthorn/forms/samples/library/resources/
    cocoon/gsoc/mpfingsthorn/forms/samples/library/resources/result_jx.xml   (with props)
    cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap   (with props)
Removed:
    cocoon/gsoc/mpfingsthorn/forms/svn-commit.2.tmp
    cocoon/gsoc/mpfingsthorn/forms/svn-commit.tmp
Modified:
    cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/cocoon-forms.xconf
    cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/forms.logkit
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/DefaultFormManager.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/AbstractContainerDefinitionBuilder.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/ButtonDefinitionBuilder.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/NewDefinition.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilder.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java
    cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java
    cocoon/gsoc/mpfingsthorn/forms/samples/welcome.xml

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=239913&r1=239912&r2=239913&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 13:08:52 2005
@@ -138,6 +138,7 @@
   <forms-formmanager>
     <widgets>
       <widget name="form" src="org.apache.cocoon.forms.formmodel.FormDefinitionBuilder"/>
+      <widget name="import" src="org.apache.cocoon.forms.formmodel.ImportDefinitionBuilder"/>
       <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/WEB-INF/xconf/forms.logkit
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/forms.logkit?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/forms.logkit (original)
+++ cocoon/gsoc/mpfingsthorn/forms/WEB-INF/xconf/forms.logkit Wed Aug 24 13:08:52 2005
@@ -30,6 +30,11 @@
       <append>false</append>
     </cocoon>
   </targets>
+  <!--categories>
+    <category log-level="DEBUG" name="forms">
+      <log-target id-ref="forms" />
+    </category>
+  </categories-->
   <categories>
     <category log-level="@loglevel@" name="forms">
       <log-target id-ref="forms" />

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/DefaultFormManager.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/DefaultFormManager.java?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/DefaultFormManager.java (original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/DefaultFormManager.java Wed Aug 24 13:08:52 2005
@@ -27,12 +27,15 @@
 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.formmodel.Form;
 import org.apache.cocoon.forms.formmodel.FormDefinition;
 import org.apache.cocoon.forms.formmodel.FormDefinitionBuilder;
 import org.apache.cocoon.forms.formmodel.WidgetDefinitionBuilder;
+import org.apache.cocoon.forms.formmodel.library.LibraryManager;
+import org.apache.cocoon.forms.formmodel.library.LibraryManagerImpl;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.apache.cocoon.forms.util.SimpleServiceSelector;
 import org.apache.excalibur.source.Source;
@@ -55,6 +58,8 @@
     protected Configuration configuration;
     protected SimpleServiceSelector widgetDefinitionBuilderSelector;
     protected CacheManager cacheManager;
+    
+    protected LibraryManagerImpl libraryManager;
 
     private Context avalonContext;
     public void contextualize(Context context) throws ContextException {
@@ -80,31 +85,22 @@
     }
 
     public void initialize() throws Exception {
+
+        libraryManager = new LibraryManagerImpl();
+        libraryManager.enableLogging(getLogger().getChildLogger("library"));
+        libraryManager.service(new FormServiceManager());
+        libraryManager.configure(configuration.getChild("libraries"));
+        
         widgetDefinitionBuilderSelector = new SimpleServiceSelector("widget", WidgetDefinitionBuilder.class);
         widgetDefinitionBuilderSelector.contextualize(avalonContext);
-        widgetDefinitionBuilderSelector.service(new ServiceManager() {
-            final String WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE = WidgetDefinitionBuilder.class.getName() + "Selector";
-
-            public Object lookup(String name) throws ServiceException {
-                if (WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE.equals(name))
-                    return widgetDefinitionBuilderSelector;
-                else
-                    return manager.lookup(name);
-            }
-
-            public boolean hasService(String name) {
-                if (WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE.equals(name))
-                    return true;
-                else
-                    return manager.hasService(name);
-            }
-
-            public void release(Object service) {
-                if (service != widgetDefinitionBuilderSelector)
-                    manager.release(service);
-            }
-        });
+        widgetDefinitionBuilderSelector.service(new FormServiceManager());
         widgetDefinitionBuilderSelector.configure(configuration.getChild("widgets"));
+        
+        libraryManager.initialize();
+    }
+    
+    public ServiceSelector getWidgetDefinitionBuilderSelector() {
+    	return this.widgetDefinitionBuilderSelector;
     }
 
     public Form createForm(Source source) throws Exception {
@@ -210,8 +206,42 @@
             this.widgetDefinitionBuilderSelector.dispose();
             this.widgetDefinitionBuilderSelector = null;
         }
+        if(this.libraryManager != null) {
+        	this.libraryManager.dispose();
+        	this.libraryManager = null;
+        }
         this.manager.release(this.cacheManager);
         this.cacheManager = null;
         this.manager = null;
+    }
+    
+    
+    public class FormServiceManager implements ServiceManager {
+        final String WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE = WidgetDefinitionBuilder.class.getName() + "Selector";
+        final String LIBRARY_MANAGER_ROLE = LibraryManager.ROLE;
+
+        public Object lookup(String name) throws ServiceException {
+            if (WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE.equals(name))
+                return widgetDefinitionBuilderSelector;
+            else if(LIBRARY_MANAGER_ROLE.equals(name))
+            	return libraryManager;
+            else
+                return manager.lookup(name);
+        }
+
+        public boolean hasService(String name) {
+            if (WIDGET_DEFINITION_BUILDER_SELECTOR_ROLE.equals(name))
+                return true;
+            else if(LIBRARY_MANAGER_ROLE.equals(name))
+            	return true;
+            else
+                return manager.hasService(name);
+        }
+
+        public void release(Object service) {
+            if (service != widgetDefinitionBuilderSelector
+            		&& service != libraryManager)
+                manager.release(service);
+        }
     }
 }

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=239913&r1=239912&r2=239913&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 13:08:52 2005
@@ -17,8 +17,23 @@
         if(widgetElements!=null)
         for (int i = 0; i < widgetElements.length; i++) {
             Element widgetElement = widgetElements[i];
+            
+            String newId = null;
+            WidgetDefinition def = null;
+            if(this.context !=null)
+	            if((newId = (String)widgetElement.getAttribute("extends")) != null) {
+	            	if((def = definition.getWidgetDefinition(newId))!=null)
+	            		this.context.setSuperDefinition(def);
+	            	else if((def = this.context.getLocalLibrary().getDefinition(newId))!=null)
+	            		this.context.setSuperDefinition(def);
+	            }
+	            else
+	            	this.context.setSuperDefinition(null);
+                
             WidgetDefinition widgetDefinition = buildAnotherWidgetDefinition(widgetElement);
-            definition.addWidgetDefinition(widgetDefinition);
+            
+            if(widgetDefinition!=null)
+            	definition.addWidgetDefinition(widgetDefinition);
         }
         
     }

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=239913&r1=239912&r2=239913&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 13:08:52 2005
@@ -76,6 +76,7 @@
     	// TODO: don't know what else to check now
     }
     
+    
     /**
      * Locks this definition so that it becomes immutable.
      */

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=239913&r1=239912&r2=239913&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 13:08:52 2005
@@ -34,7 +34,6 @@
 import org.apache.cocoon.forms.event.WidgetListener;
 import org.apache.cocoon.forms.event.WidgetListenerBuilder;
 import org.apache.cocoon.forms.expression.ExpressionManager;
-import org.apache.cocoon.forms.formmodel.library.Library;
 import org.apache.cocoon.forms.util.DomHelper;
 import org.apache.cocoon.forms.validation.WidgetValidatorBuilder;
 import org.apache.excalibur.xml.sax.XMLizable;
@@ -56,12 +55,19 @@
     protected ExpressionManager expressionManager;
     protected ServiceManager serviceManager;
     
-    protected Library library = null;
+    protected WidgetDefinitionBuilderContext context = null;
     
-    public WidgetDefinition buildWidgetDefinition(Element widgetElement, Library localLibrary) throws Exception {
-    	this.library =  localLibrary;
+    public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context) throws Exception {
+    	// so changes don't pollute upper levels
+    	this.context = new WidgetDefinitionBuilderContext(context);
     	WidgetDefinition def = buildWidgetDefinition(widgetElement);
-    	this.library = null;
+    	
+    	// register this class with the local library, if any.
+        if(DomHelper.getAttributeAsBoolean(widgetElement,"register",false) && this.context!=null && this.context.getLocalLibrary()!=null) {
+        	this.context.getLocalLibrary().addDefinition(def);
+        }
+        
+    	this.context = null;
     	return def;
     }
 
@@ -133,7 +139,7 @@
             throw new CascadingException("Unknown kind of widget '" + widgetName + "' at " +
                                          DomHelper.getLocation(widgetDefinition), e);
         }
-        return builder.buildWidgetDefinition(widgetDefinition);
+        return builder.buildWidgetDefinition(widgetDefinition, this.context);
     }
 
     protected List buildEventListeners(Element widgetElement, String elementName, Class listenerClass) throws Exception {

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java (original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ButtonDefinitionBuilder.java Wed Aug 24 13:08:52 2005
@@ -16,7 +16,6 @@
 package org.apache.cocoon.forms.formmodel;
 
 import org.w3c.dom.Element;
-import org.apache.cocoon.forms.formmodel.library.Library;
 import org.apache.cocoon.forms.util.DomHelper;
 
 /**
@@ -25,11 +24,7 @@
  * 
  * @version $Id: ButtonDefinitionBuilder.java 56582 2004-11-04 10:16:22Z sylvain $
  */
-public class ButtonDefinitionBuilder implements WidgetDefinitionBuilder {
-	
-	public WidgetDefinition buildWidgetDefinition(Element widgetElement, Library lib) throws Exception {
-		throw new Exception("The button widget has been renamed to action. Please update your form definition files. Found at " + DomHelper.getLocation(widgetElement));
-	}
+public class ButtonDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
 	
     public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
         throw new Exception("The button widget has been renamed to action. Please update your form definition files. Found at " + DomHelper.getLocation(widgetElement));

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java (original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ClassDefinitionBuilder.java Wed Aug 24 13:08:52 2005
@@ -33,6 +33,7 @@
         setupContainer(element,"widgets",definition);
 
         definition.makeImmutable();
+        
         return definition;
     }
 }

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinition.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinition.java?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinition.java (original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinition.java Wed Aug 24 13:08:52 2005
@@ -21,6 +21,8 @@
 import org.apache.cocoon.forms.event.ProcessingPhaseEvent;
 import org.apache.cocoon.forms.event.ProcessingPhaseListener;
 import org.apache.cocoon.forms.event.WidgetEventMulticaster;
+import org.apache.cocoon.forms.formmodel.library.Library;
+import org.apache.cocoon.forms.formmodel.library.LibraryManager;
 
 /**
  * The {@link WidgetDefinition} part of a Form widget, see {@link Form} for more information.
@@ -29,9 +31,16 @@
  */
 public class FormDefinition extends AbstractContainerDefinition {
     private ProcessingPhaseListener listener;
+    
+    private Library localLibrary = null;
 
-    public FormDefinition() {
+    public FormDefinition(LibraryManager libraryManager) {
         super();
+        localLibrary = libraryManager.getNewLibrary();
+    }
+    
+    public Library getLocalLibrary() {
+    	return localLibrary;
     }
 
     public void resolve() throws Exception {

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java (original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java Wed Aug 24 13:08:52 2005
@@ -15,6 +15,9 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.forms.formmodel.library.LibraryManager;
 import org.w3c.dom.Element;
 
 /**
@@ -24,8 +27,22 @@
  */
 public final class FormDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
+	protected LibraryManager libraryManager;
+	
+	public void service(ServiceManager manager) throws ServiceException {
+		super.service(manager);
+		
+		libraryManager = (LibraryManager) serviceManager.lookup(LibraryManager.ROLE);
+	}
+	
+	public WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context) throws Exception {
+    	throw new UnsupportedOperationException("Please use the other signature without WidgetDefinitionBuilderContext!");
+    }
+	
     public WidgetDefinition buildWidgetDefinition(Element formElement) throws Exception {
-        FormDefinition formDefinition = new FormDefinition();
+        FormDefinition formDefinition = new FormDefinition(libraryManager);
+        this.context = new WidgetDefinitionBuilderContext();
+        this.context.setLocalLibrary(formDefinition.getLocalLibrary());
         
         super.setupDefinition(formElement, formDefinition);
         setDisplayData(formElement, formDefinition);
@@ -35,6 +52,8 @@
         formDefinition.resolve();
 
         formDefinition.makeImmutable();
+        
+        this.context = null;
         return formDefinition;
     }
 }

Added: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java?rev=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java (added)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java Wed Aug 24 13:08:52 2005
@@ -0,0 +1,57 @@
+/*
+ * 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;
+import org.apache.cocoon.forms.util.DomHelper;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Max Pfingsthorn (mpfingsthorn@hippo.nl)
+ *
+ */
+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 = widgetElement.getAttribute(PREFIX_ATTRIBUTE);
+		String uri = widgetElement.getAttribute(URI_ATTRIBUTE);
+		
+		if(uri == null || "".equals(uri))
+			throw new Exception("Import statement must define a uri to import from! (at "+DomHelper.getLocation(widgetElement)+")");
+		
+		if(prefix == null || "".equals(prefix))
+			throw new Exception("Import statement must define a prefix for the imported library! (at "+DomHelper.getLocation(widgetElement)+")");
+		
+		if(!lib.includeAs(prefix,uri))
+			throw new Exception("Import statement did not succeed (probably used ':' in the prefix?)! (at "+DomHelper.getLocation(widgetElement)+")");
+		
+		return null;
+	}
+
+}

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=239913&r1=239912&r2=239913&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 13:08:52 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))

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilder.java?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilder.java (original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilder.java Wed Aug 24 13:08:52 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
-import org.apache.cocoon.forms.formmodel.library.Library;
 import org.w3c.dom.Element;
 
 /**
@@ -33,5 +32,5 @@
 
     WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception;
 
-    WidgetDefinition buildWidgetDefinition(Element widgetElement, Library localLibrary) throws Exception;
+    WidgetDefinition buildWidgetDefinition(Element widgetElement, WidgetDefinitionBuilderContext context) throws Exception;
 }

Added: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java?rev=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java (added)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionBuilderContext.java Wed Aug 24 13:08:52 2005
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ * 
+ * @author Max Pfingsthorn (mpfingsthorn@hippo.nl)
+ *
+ */
+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;
+	}
+	
+}

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java (original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/Library.java Wed Aug 24 13:08:52 2005
@@ -20,14 +20,12 @@
 import java.util.Map;
 
 import org.apache.avalon.framework.CascadingException;
-import org.apache.avalon.framework.activity.Disposable;
 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.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.w3c.dom.Element;
@@ -36,11 +34,10 @@
  * @author Max Pfingsthorn (mpfingsthorn@hippo.nl)
  *
  */
-public class Library implements Serviceable, Disposable {
+public class Library {
 
 	public static final String SEPARATOR = ":";
 	
-	protected ServiceManager serviceManager= null;
 	
 	// managed instances
 	protected ServiceSelector widgetDefinitionBuilderSelector;
@@ -52,25 +49,38 @@
 	protected Map definitions = new HashMap();
 	protected Map inclusions = new HashMap();
 	
+	// my uri
+	protected String source = null;
+	
+	// shared object with dependencies
+	protected Object shared = new Object();
+	
+	protected WidgetDefinitionBuilderContext context;
+	
 	public Library(LibraryManager lm) {
 		manager = lm;
+		context = new WidgetDefinitionBuilderContext();
+		context.setLocalLibrary(this);
 	}
 	
-	public void service(ServiceManager manager) throws ServiceException{
-		this.serviceManager = manager;
-		this.widgetDefinitionBuilderSelector = (ServiceSelector) serviceManager.lookup(WidgetDefinitionBuilder.class.getName() + "Selector");
+	void setSource(String source) {
+		this.source = source;
 	}
 	
-	public void dispose() {
-		this.serviceManager.release(this.widgetDefinitionBuilderSelector);
+	public String toString() {
+		return getClass().getName()+":"+source;
+	}
+	
+	public void setWidgetDefinitionBuilderSelector(ServiceSelector selector) {
+		this.widgetDefinitionBuilderSelector = selector;
 	}
 	
 	public boolean dependenciesHaveChanged() throws Exception {
 		
 		Iterator it = this.inclusions.values().iterator();
 		while(it.hasNext()) {
-			String source = (String)it.next();
-			if(!this.manager.libraryInCache(source))
+			Dependency dep = (Dependency)it.next();
+			if(!dep.isValid())
 				return true;
 		}
 		
@@ -78,7 +88,8 @@
 	}
 	
 	/**
-	 * "registers" a 
+	 * "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"
@@ -91,7 +102,7 @@
 			// library keys may not contain ":"!
 			if( (!inclusions.containsKey(key) || key.indexOf(SEPARATOR)>-1) 
 					&& manager.getLibrary(librarysource)!=null) {
-				inclusions.put(key,librarysource);
+				inclusions.put(key,new Dependency(librarysource));
 				return true;
 			}
 			return false;
@@ -101,9 +112,7 @@
 		
 	}
 	
-	public WidgetDefinition getDefinition(String key)
-		throws LibraryException
-	{
+	public WidgetDefinition getDefinition(String key) throws LibraryException {
 		
 		String librarykey = null;
 		String definitionkey = key;
@@ -120,7 +129,7 @@
 		if(librarykey!=null) {
 			if(inclusions.containsKey(librarykey)) {
 				try {
-					return manager.getLibrary((String)inclusions.get(librarykey)).getDefinition(definitionkey);
+					return manager.getLibrary(((Dependency)inclusions.get(librarykey)).sourceURI).getDefinition(definitionkey);
 				} catch(Exception e) {
 					throw new LibraryException("Couldn't get Library key='"+librarykey+"' source='"+inclusions.get(librarykey)+"",e);
 				}
@@ -139,10 +148,18 @@
         for (int i = 0; i < widgetElements.length; i++) {
             Element widgetElement = widgetElements[i];
             WidgetDefinition widgetDefinition = buildWidgetDefinition(widgetElement);
-            definitions.put(widgetDefinition.getId(),widgetDefinition);
+            addDefinition(widgetDefinition);
         }
 	}
 	
+	public void addDefinition(WidgetDefinition definition) throws LibraryException {
+		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;
@@ -152,6 +169,44 @@
             throw new CascadingException("Unknown kind of widget '" + widgetName + "' at " +
                                          DomHelper.getLocation(widgetDefinition), e);
         }
-        return builder.buildWidgetDefinition(widgetDefinition,this);
+        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 sourceURI;
+		private Object shared;
+		
+		public Dependency(String sourceURI) throws Exception {
+			this.sourceURI = sourceURI;
+			
+			Library lib = manager.getLibrary(sourceURI);
+			this.shared = lib.shared;
+		}
+		
+		public boolean isValid() throws LibraryException {
+			try {
+				
+				if(manager.libraryInCache(sourceURI)) {
+					Library lib = manager.getLibrary(sourceURI);
+					
+					if(this.shared == lib.shared)
+						return false;
+				}
+				
+				return true;
+			} catch(Exception forward) {
+				throw new LibraryException("Exception occured while checking dependency validity!",forward);
+			}
+			
+		}
+	}
+	
 }

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java (original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java Wed Aug 24 13:08:52 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.cocoon.forms.formmodel.library;
 
-import org.apache.cocoon.forms.datatype.DatatypeManager;
 
 
 /**
@@ -28,9 +27,12 @@
  */
 public interface LibraryManager {
 
-	String ROLE = DatatypeManager.class.getName();
+	String ROLE = LibraryManager.class.getName();
 	
 	Library getLibrary(String librarysource) throws Exception;
+	Library getNewLibrary();
 	
 	boolean libraryInCache(String librarysource) throws Exception;
+	
+	void debug(String msg);
 }

Modified: cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java (original)
+++ cocoon/gsoc/mpfingsthorn/forms/java/org/apache/cocoon/forms/formmodel/library/LibraryManagerImpl.java Wed Aug 24 13:08:52 2005
@@ -24,9 +24,11 @@
 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;
@@ -45,9 +47,12 @@
 	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 {
@@ -56,6 +61,8 @@
     }
     
     public void initialize() throws Exception {
+    	this.widgetDefinitionBuilderSelector = (ServiceSelector) serviceManager.lookup(WidgetDefinitionBuilder.class.getName() + "Selector");
+    	
         // read config to "preload" libraries
     }
     
@@ -75,8 +82,10 @@
             
             lib = (Library)this.cacheManager.get(source, PREFIX);
             
-            if( lib != null && lib.dependenciesHaveChanged() )
+            if( lib != null && lib.dependenciesHaveChanged() ) {
             	result = false;
+            	this.cacheManager.set(null,source,PREFIX); //evict?
+            }
             else if( lib == null )
             	result = false;
             else
@@ -134,8 +143,7 @@
                     inputSource.setSystemId(source.getURI());
                     libraryDocument = DomHelper.parse(inputSource, this.serviceManager);
                     
-                    lib = new Library(this);
-                    lib.service(this.serviceManager);
+                    lib = getNewLibrary();
                     lib.buildLibrary(libraryDocument.getDocumentElement());
                     
                     this.cacheManager.set(lib,source,PREFIX);
@@ -154,11 +162,24 @@
 
         return lib;
 	}
+	
+	public Library getNewLibrary() {
+		Library lib = new Library(this);
+        lib.setWidgetDefinitionBuilderSelector(this.widgetDefinitionBuilderSelector);
+        
+        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);
+		}
 	}
 	
 }

Added: cocoon/gsoc/mpfingsthorn/forms/samples/library/flow/library.js
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/library/flow/library.js?rev=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/flow/library.js (added)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/flow/library.js Wed Aug 24 13:08:52 2005
@@ -0,0 +1,130 @@
+/*
+* 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.
+*/
+
+/*
+* @version $Id: swan.js 158090 2005-03-18 16:34:35Z tim $
+*/
+
+  importPackage(org.apache.cocoon.forms.formmodel);
+
+cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
+
+function show_form1(form) {
+    process_form(form, "form1", "forms/form1_data.xml");
+}
+
+function process_form(form, type, input) {
+
+    var locale = determineLocale();
+    var model = form.getModel();
+    form.locale = locale;
+
+    
+    // parse the document to a DOM-tree
+    var document = loadDocument(input);
+
+    // bind the document data to the form
+    form.load(document);
+
+    // show the form
+    form.showForm(type + "-display-pipeline");
+    print("submitId = " + form.submitId);
+    if (form.isValid) {
+      print("Form is valid");  
+    } else {
+      print("Form is not valid");
+    }
+
+
+    // bind the form's data back to the document
+    form.save(document);
+
+    // save the DOM-tree back to an XML file, the makeTargetURI
+    // function makes a modified filename so that the
+    // original document is not overwritten
+    //saveDocument(document, makeTargetURI(documentURI));
+
+    // show the xml generated from the form
+    var bizdata = { "document" : document };
+    cocoon.sendPage(type + "-success-pipeline.jx", bizdata);
+}
+
+function determineLocale() {
+    var localeParam = cocoon.request.get("locale");
+    if (localeParam != null && localeParam.length > 0) {
+        return Packages.org.apache.cocoon.i18n.I18nUtils.parseLocale(localeParam);
+    }
+    return null;
+}
+
+function loadDocument(uri) {
+    var parser = null;
+    var source = null;
+    var resolver = null;
+    try {
+        parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+        resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+        source = resolver.resolveURI(uri);
+        var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
+        is.setSystemId(source.getURI());
+        return parser.parseDocument(is);
+    } finally {
+        if (source != null)
+            resolver.release(source);
+        cocoon.releaseComponent(parser);
+        cocoon.releaseComponent(resolver);
+    }
+}
+
+function saveDocument(document, uri) {
+    var source = null;
+    var resolver = null;
+    var outputStream = null;
+    try {
+        resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+        source = resolver.resolveURI(uri);
+
+        var tf = Packages.javax.xml.transform.TransformerFactory.newInstance();
+
+        if (source instanceof Packages.org.apache.excalibur.source.ModifiableSource
+            && tf.getFeature(Packages.javax.xml.transform.sax.SAXTransformerFactory.FEATURE)) {
+
+            outputStream = source.getOutputStream();
+            var transformerHandler = tf.newTransformerHandler();
+            var transformer = transformerHandler.getTransformer();
+            transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.INDENT, "true");
+            transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.METHOD, "xml");
+            transformerHandler.setResult(new Packages.javax.xml.transform.stream.StreamResult(outputStream));
+
+            var streamer = new Packages.org.apache.cocoon.xml.dom.DOMStreamer(transformerHandler);
+            streamer.stream(document);
+        } else {
+            throw new Packages.org.apache.cocoon.ProcessingException("Cannot write to source " + uri);
+        }
+    } finally {
+        if (source != null)
+            resolver.release(source);
+        cocoon.releaseComponent(resolver);
+        if (outputStream != null) {
+            try {
+                outputStream.flush();
+                outputStream.close();
+            } catch (error) {
+                cocoon.log.error("Could not flush/close outputstream: " + error);
+            }
+        }
+    }
+}

Added: 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=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_binding.xml (added)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_binding.xml Wed Aug 24 13:08:52 2005
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<fb:context 
+  xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" 
+  xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" 
+  path="/data" >
+  
+  <fb:value id="field1" path="field1"/>
+  
+</fb:context>
\ No newline at end of file

Propchange: cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_binding.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_data.xml
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_data.xml?rev=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_data.xml (added)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_data.xml Wed Aug 24 13:08:52 2005
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<data>
+  <field1/>
+</data>
\ No newline at end of file

Propchange: cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_data.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_model.xml (added)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_model.xml Wed Aug 24 13:08:52 2005
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<fd:form
+  xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+  
+  <fd:widgets>
+    <fd:import prefix="lib" uri="cocoon:/library/library_form1.xml"/>
+    
+    <fd:new id="lib:class1"/>
+  </fd:widgets>
+</fd:form>
\ No newline at end of file

Propchange: cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_model.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_template.xml (added)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_template.xml Wed Aug 24 13:08:52 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
+  xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
+  <title>Registration</title>
+  <content>
+    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST">
+      <fi:group>
+        <fi:styling layout="columns"/>
+        <fi:items>
+          <ft:widget id="field1"/>
+        </fi:items>
+      </fi:group>
+      <input type="submit"/>
+    </ft:form-template>
+  </content>
+</page>
\ No newline at end of file

Propchange: cocoon/gsoc/mpfingsthorn/forms/samples/library/forms/form1_template.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 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=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/library_form1.xml (added)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/library_form1.xml Wed Aug 24 13:08:52 2005
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<fd:library
+  xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+  <fd:widgets>
+    <fd:class id="class1">
+      <fd:widgets>
+        <fd:field id="field1">
+          <fd:label>Field:</fd:label>
+          <fd:datatype base="string"/>
+        </fd:field>
+      </fd:widgets>
+    </fd:class>
+  </fd:widgets>
+</fd:library>
\ No newline at end of file

Propchange: cocoon/gsoc/mpfingsthorn/forms/samples/library/libraries/library_form1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/gsoc/mpfingsthorn/forms/samples/library/resources/result_jx.xml
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/library/resources/result_jx.xml?rev=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/resources/result_jx.xml (added)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/resources/result_jx.xml Wed Aug 24 13:08:52 2005
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+  ${document}
+</jx:template>
\ No newline at end of file

Propchange: cocoon/gsoc/mpfingsthorn/forms/samples/library/resources/result_jx.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap?rev=239913&view=auto
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap (added)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap Wed Aug 24 13:08:52 2005
@@ -0,0 +1,152 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  
+  <map:components>
+    
+    <map:transformers default="xslt">    
+      <map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
+        <catalogues default="other">
+          <catalogue id="other" name="OtherMessages" location="messages"/>
+          <catalogue id="forms" name="FormsMessages" location="messages"/>
+        </catalogues>
+        <cache-at-startup>true</cache-at-startup>
+      </map:transformer>
+    </map:transformers>
+    
+    <map:actions>
+      <map:action name="make-form" src="org.apache.cocoon.forms.acting.MakeFormAction" logger="forms"/>
+      <map:action name="init-form" src="org.apache.cocoon.forms.samples.InitForm1Action" logger="forms"/>
+      <map:action name="handle-form-submit" src="org.apache.cocoon.forms.acting.HandleFormSubmitAction" logger="forms"/>
+    </map:actions>
+    
+    <map:pipes default="caching">
+      <map:pipe name="caching" src="org.apache.cocoon.components.pipeline.impl.CachingProcessingPipeline"/>
+      <map:pipe name="noncaching" src="org.apache.cocoon.components.pipeline.impl.NonCachingProcessingPipeline"/>
+    </map:pipes>
+    
+  </map:components>
+  
+  <map:views>
+    <map:view name="content" from-label="content">
+      <map:serialize type="xml"/>
+    </map:view>
+    
+    <map:view from-label="content" name="pretty-content">
+      <map:transform src="context://stylesheets/system/xml2html.xslt"/>
+      <map:serialize type="html"/>
+    </map:view>
+    
+    <map:view name="links" from-position="last">
+      <map:serialize type="links"/>
+    </map:view>
+  </map:views>
+  
+  <map:resources>
+    <!-- this will later become a virtual transformer -->
+    <map:resource name="simple-page2html">
+      <map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
+        <map:parameter name="contextPath" value="{request:contextPath}"/>
+        <map:parameter name="servletPath" value="{request:servletPath}"/>
+        <map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
+        <map:parameter name="file" value="{file}"/>
+        <map:parameter name="remove" value="{../0}"/>
+      </map:transform> 
+    </map:resource>
+  </map:resources>
+  
+  <!-- indicates what flowscript to attach to this sitemap -->
+  <map:flow language="javascript">
+    <map:script src="flow/library.js"/>
+  </map:flow>
+  
+  <map:pipelines>
+    
+    <map:pipeline type="noncaching">
+      
+      <map:match pattern="">
+        <map:generate src="index.xml"/>
+        <map:serialize/>
+      </map:match>
+      
+      <map:match pattern="*.continue">
+        <map:call continuation="{1}"/>
+      </map:match>
+      
+      <map:match pattern="*-display-pipeline">
+        <!-- pipeline to show the form -->
+        <map:generate src="forms/{1}_template.xml"/>
+        <map:transform type="forms"/>
+        <map:transform type="i18n">
+          <map:parameter name="locale" value="en-US"/>
+        </map:transform>
+        <map:call resource="simple-page2html">
+          <map:parameter name="file" value="forms/{1}_template.xml"/>
+        </map:call>
+        <map:transform src="../resources/forms-samples-styling.xsl"/>
+        <map:serialize/>
+      </map:match>
+      
+      <map:match pattern="*-error-pipeline">
+        <map:generate src="error.xml"/>
+        <map:serialize/>
+      </map:match>
+      
+      <map:match pattern="*-success-pipeline.jx">
+        <map:generate type="jx" src="resources/result_jx.xml"/>
+        <map:call resource="simple-page2html">
+          <map:parameter name="file" value="resources/result_jx.xml"/>
+        </map:call>
+        <map:serialize/>
+      </map:match>
+      
+      <map:match pattern="resources/**">
+        <map:read src="resource://org/apache/cocoon/forms/{0}"/>
+      </map:match>
+      
+      <map:match pattern="library/**">
+        <map:read src="libraries/{1}"/>
+      </map:match>
+      
+      <!--
+         | Sample building a forms-form-gui editor in forms
+         | Doubles as a showcase for class, new, struct, union widgets
+         -->
+      
+      <!-- TODO: Fix edit-any-file security hole! -->
+      <map:match pattern="*.flow">
+        <map:call function="handleForm">
+          <map:parameter name="function" value="show_{1}"/>
+          <map:parameter name="form-definition" value="forms/{1}_model.xml"/>
+          <map:parameter name="bindingURI" value="forms/{1}_binding.xml"/>
+        </map:call>
+      </map:match>
+      
+      
+      <map:match pattern="*">
+        <map:redirect-to uri="{1}/"/>
+      </map:match>
+      
+      <map:match pattern="*/**">
+        <map:mount check-reload="yes" src="{1}/" uri-prefix="{1}"/>
+      </map:match>
+      
+    </map:pipeline>
+  </map:pipelines>
+  
+</map:sitemap>

Propchange: cocoon/gsoc/mpfingsthorn/forms/samples/library/sitemap.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/gsoc/mpfingsthorn/forms/samples/welcome.xml
URL: http://svn.apache.org/viewcvs/cocoon/gsoc/mpfingsthorn/forms/samples/welcome.xml?rev=239913&r1=239912&r2=239913&view=diff
==============================================================================
--- cocoon/gsoc/mpfingsthorn/forms/samples/welcome.xml (original)
+++ cocoon/gsoc/mpfingsthorn/forms/samples/welcome.xml Wed Aug 24 13:08:52 2005
@@ -150,4 +150,11 @@
   <sample name="Swan" href="swan/">Start page</sample>
  </group>
 
+  <group name="Forms Library samples">
+    <note>
+      This demonstrates the new library subsystem of Cocoon Forms.
+    </note>
+    <sample name="Basic Sample" href="library/form1.form">Basic Sample</sample>
+  </group>
+
 </samples>



Mime
View raw message