cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r446974 [2/3] - in /cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel: ./ library/ tree/ tree/builder/
Date Sat, 16 Sep 2006 23:39:10 GMT
Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/FormDefinitionBuilder.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -26,34 +26,35 @@
 
 /**
  * Builds {@link FormDefinition}s.
- * 
+ *
  * @version $Id$
  */
 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 {
+
+	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(libraryManager);
         this.context = new WidgetDefinitionBuilderContext();
         this.context.setLocalLibrary(formDefinition.getLocalLibrary());
-        
+
         // set local URI
         formDefinition.getLocalLibrary().setSourceURI(LocationAttributes.getURI(formElement));
-    
-        Iterator iter = buildEventListeners(formElement, "on-processing-phase", ProcessingPhaseListener.class).iterator();
-        while (iter.hasNext()) {
-            formDefinition.addProcessingPhaseListener((ProcessingPhaseListener)iter.next());
+
+        Iterator i = buildEventListeners(formElement, "on-processing-phase", ProcessingPhaseListener.class).iterator();
+        while (i.hasNext()) {
+            formDefinition.addProcessingPhaseListener((ProcessingPhaseListener) i.next());
         }
         
         super.setupDefinition(formElement, formDefinition);
@@ -64,7 +65,7 @@
         formDefinition.resolve();
 
         formDefinition.makeImmutable();
-        
+
         this.context = null;
         return formDefinition;
     }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/ImportDefinitionBuilder.java Sat Sep 16 16:39:08 2006
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -27,24 +27,27 @@
 
 	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();
+    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;
-	}
 
+        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/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/IncompletenessException.java Sat Sep 16 16:39:08 2006
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -22,9 +22,10 @@
  */
 public class IncompletenessException extends CascadingException {
 
-	private WidgetDefinition causingDefinition = null;
+	private WidgetDefinition causingDefinition;
 
-	public IncompletenessException(String message, WidgetDefinition incomplete) {
+
+    public IncompletenessException(String message, WidgetDefinition incomplete) {
         super(message);
         causingDefinition = incomplete;
     }
@@ -33,13 +34,13 @@
         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;
+
+        if (causingDefinition != null)
+            msg += " (Caused by widget '" + causingDefinition.getId() + "', last modified at " + causingDefinition.getLocation() + ")";
+
+        return msg;
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueField.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueField.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueField.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueField.java Sat Sep 16 16:39:08 2006
@@ -206,7 +206,8 @@
         } else if (value.getClass().isArray()) {
             setValues((Object[])value);
         } else {
-            throw new RuntimeException("Cannot set value of field \"" + getRequestParameterName() + "\" with an object of type " + value.getClass().getName());
+            throw new RuntimeException("Cannot set value of field \"" + getRequestParameterName() + "\" with an object of type " +
+                                       value.getClass().getName());
         }
         getForm().addWidgetUpdate(this);
     }
@@ -214,8 +215,10 @@
     public void setValues(Object[] values) {
         // check that all the objects in the array correspond to the datatype
         for (int i = 0; i < values.length; i++) {
-            if (!definition.getDatatype().getTypeClass().isAssignableFrom(values[i].getClass()))
-                throw new RuntimeException("Cannot set value of field \"" + getRequestParameterName() + "\" with an object of type " + values[i].getClass().getName());
+            if (!definition.getDatatype().getTypeClass().isAssignableFrom(values[i].getClass())) {
+                throw new RuntimeException("Cannot set value of field \"" + getRequestParameterName() + "\" with an object of type " +
+                                           values[i].getClass().getName());
+            }
         }
         Object[] oldValues = this.values;
         this.values = values;
@@ -233,8 +236,7 @@
         }
 
         if (selectionList.getDatatype() != null &&
-            selectionList.getDatatype() != definition.getDatatype()) {
-
+                selectionList.getDatatype() != definition.getDatatype()) {
             throw new RuntimeException("Tried to assign a SelectionList that is not associated with this widget's datatype.");
         }
         this.selectionList = selectionList;

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinition.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/MultiValueFieldDefinition.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -17,13 +17,13 @@
 
 /**
  * The {@link WidgetDefinition} part of a MultiValueField widget, see {@link MultiValueField} for more information.
- * 
+ *
  * @version $Id$
  */
 public class MultiValueFieldDefinition extends FieldDefinition {
+
     public Widget createInstance() {
-        MultiValueField field =  new MultiValueField(this);
-        return field;
+        return new MultiValueField(this);
     }
 
 	public void setRequired(boolean required) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/NewDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/NewDefinition.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/NewDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/NewDefinition.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -40,23 +40,29 @@
     private ClassDefinition getClassDefinition() throws Exception {
         FormDefinition formDefinition = getFormDefinition();
         WidgetDefinition classDefinition = null;
-        
+
         // we found a form definition to ask
-        if( formDefinition != null ) {
-        	classDefinition = formDefinition.getWidgetDefinition(getId());
-        	
-        	if (classDefinition == null) // not found in local form, try library
+        if (formDefinition != null) {
+            classDefinition = formDefinition.getWidgetDefinition(getId());
+
+            if (classDefinition == null) { // not found in local form, try library
             	classDefinition = formDefinition.getLocalLibrary().getDefinition(getId());
+            }
+        }
+
+        if (classDefinition == null && getEnclosingLibrary() != null) { // not found in form's library, so ask enclosing library
+            classDefinition = getEnclosingLibrary().getDefinition(getId());
         }
-        
-        if (classDefinition == null && getEnclosingLibrary() != null) // not found in form's library, so ask enclosing library
-        	classDefinition = getEnclosingLibrary().getDefinition(getId());
-        
-        if (classDefinition == null)
+
+        if (classDefinition == null) {
             throw new Exception("NewDefinition: Class with id \"" + getId() + "\" does not exist (" + getLocation() + ")");
-        if (!(classDefinition instanceof ClassDefinition))
+        }
+
+        if (!(classDefinition instanceof ClassDefinition)) {
             throw new Exception("NewDefinition: Id \"" + getId() + "\" is not a class (" + getLocation() + ")");
-        return (ClassDefinition)classDefinition;
+        }
+
+        return (ClassDefinition) classDefinition;
     }
 
     // TODO: Should add checking for union defaults which would cause non-terminating recursion.
@@ -67,12 +73,17 @@
             ListIterator parentsIt = parents.listIterator(parents.size());
             while(parentsIt.hasPrevious()) {
                 WidgetDefinition definition = (WidgetDefinition)parentsIt.previous();
-                if (definition instanceof UnionDefinition) break;
-                if (definition == this)
-                    throw new Exception("NewDefinition: Non-terminating recursion detected in widget definition : "
-                        + parent.getId() + " (" + getLocation() + ")");
+                if (definition instanceof UnionDefinition) {
+                    break;
+                }
+
+                if (definition == this) {
+                    throw new Exception("NewDefinition: Non-terminating recursion detected in widget definition : " +
+                                        parent.getId() + " (" + getLocation() + ")");
+                }
             }
         }
+
         // Resolution
         resolving = true;
         parents.add(this);
@@ -85,7 +96,7 @@
             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);

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Output.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Output.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Output.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Output.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -36,7 +36,7 @@
  * {@link org.apache.cocoon.forms.datatype.Datatype Datatype}.
  *
  * <p>An Output widget is always valid and never required.
- * 
+ *
  * @version $Id$
  */
 public class Output extends AbstractWidget implements DataWidget, ValueChangedListenerEnabled {
@@ -126,7 +126,7 @@
         if (!ObjectUtils.equals(value, object)) {
             Object oldValue = value;
             value = object;
-            if (this.hasValueChangedListeners() || this.getForm().hasFormHandler()) {
+            if (hasValueChangedListeners() || getForm().hasFormHandler()) {
                 getForm().addWidgetEvent(new ValueChangedEvent(this, oldValue, value));
             }
             getForm().addWidgetUpdate(this);

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/OutputDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/OutputDefinition.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/OutputDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/OutputDefinition.java Sat Sep 16 16:39:08 2006
@@ -23,6 +23,7 @@
  * @version $Id$
  */
 public class OutputDefinition extends AbstractDatatypeWidgetDefinition {
+
     public Widget createInstance() {
         return new Output(this);
     }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Repeater.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Repeater.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Repeater.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Repeater.java Sat Sep 16 16:39:08 2006
@@ -66,7 +66,7 @@
     protected ValidationError validationError;
     private boolean orderable = false;
     private RepeaterListener listener;
-    
+
     // pagination
     private PageStorage storage;
     private boolean pageable = false;
@@ -81,16 +81,16 @@
         for (int i = 0; i < this.definition.getInitialSize(); i++) {
             rows.add(new RepeaterRow(definition));
         }
-        
+
         this.orderable = this.definition.getOrderable();
         this.listener = this.definition.getRepeaterListener();
-        
+
         this.pageable = this.definition.isPageable();
         if (pageable) {
         	this.currentPage = this.definition.getInitialPage();
         	this.pageSize = this.definition.getPageSize();
         }
-        
+
     }
 
     public WidgetDefinition getDefinition() {
@@ -182,7 +182,6 @@
 
         if (result == null) {
             throw new RuntimeException("Could not find a parent row for widget " + widget);
-
         }
         return (Repeater.RepeaterRow)result;
     }
@@ -213,31 +212,31 @@
      */
     public void moveRow(int from, int to) {
         int size = this.rows.size();
-        
+
         if (from < 0 || from >= size || to < 0 || to > size) {
             throw new IllegalArgumentException("Cannot move from " + from + " to " + to +
-                    " on repeater with " + size + " rows");
+                                               " on repeater with " + size + " rows");
         }
-        
+
         if (from == to) {
             return;
         }
-        
+
         Object fromRow = this.rows.remove(from);
         if (to == size) {
             // Move at the end
             this.rows.add(fromRow);
-            
+
         } else if (to > from) {
             // Index of "to" was moved by removing
             this.rows.add(to - 1, fromRow);
-            
+
         } else {
             this.rows.add(to, fromRow);
         }
 
         getForm().addWidgetUpdate(this);
-        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_REARRANGED));        
+        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_REARRANGED));
     }
 
     /**
@@ -253,7 +252,7 @@
 
         if (from < 0 || from >= size || to < 0 || to >= size) {
             throw new IllegalArgumentException("Cannot move from " + from + " to " + to +
-                    " on repeater with " + size + " rows");
+                                               " on repeater with " + size + " rows");
         }
 
         if (from == to) {
@@ -276,7 +275,7 @@
             this.rows.set(index, temp);
         }
         getForm().addWidgetUpdate(this);
-        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_REARRANGED));                
+        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_REARRANGED));
     }
 
     public void moveRowRight(int index) {
@@ -288,7 +287,7 @@
             this.rows.set(index, temp);
         }
         getForm().addWidgetUpdate(this);
-        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_REARRANGED));                
+        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_REARRANGED));
     }
 
     /**
@@ -303,9 +302,9 @@
      * Clears all rows from the repeater and go back to the initial size
      */
     public void clear() {
-        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_CLEARING));        
+        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_CLEARING));
         rows.clear();
-        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_CLEARED));        
+        broadcastEvent(new RepeaterEvent(this, RepeaterEventAction.ROWS_CLEARED));
 
         // and reset to initial size
         for (int i = 0; i < this.definition.getInitialSize(); i++) {
@@ -313,7 +312,7 @@
         }
         getForm().addWidgetUpdate(this);
     }
-    
+
     public void addRepeaterListener(RepeaterListener listener) {
         this.listener = WidgetEventMulticaster.add(this.listener, listener);
     }
@@ -336,7 +335,7 @@
             super.broadcastEvent(event);
         }
     }
-    
+
 
     /**
      * Gets a widget on a certain row.
@@ -352,11 +351,11 @@
     public void readFromRequest(FormContext formContext) {
         if (!getCombinedState().isAcceptingInputs())
             return;
-        
+
         // read number of rows from request, and make an according number of rows
         Request req = formContext.getRequest();
         String paramName = getRequestParameterName();
-        
+
         String sizeParameter = req.getParameter(paramName + ".size");
         if (sizeParameter != null) {
             int size = 0;
@@ -368,8 +367,9 @@
 
             // some protection against people who might try to exhaust the server by supplying very large
             // size parameters
-            if (size > 500)
+            if (size > 500) {
                 throw new RuntimeException("Client is not allowed to specify a repeater size larger than 500.");
+            }
 
             int currentSize = getSize();
             if (currentSize < size) {
@@ -389,7 +389,7 @@
             RepeaterRow row = (RepeaterRow)rowIt.next();
             row.readFromRequest(formContext);
         }
-        
+
         // Handle repeater-level actions
         String action = req.getParameter(paramName + ".action");
         if (action == null) {
@@ -402,9 +402,10 @@
             if (!this.orderable) {
                 throw new FormsRuntimeException(this + " is not orderable", getLocation());
             }
+
             int from = Integer.parseInt(req.getParameter(paramName + ".from"));
             int before = Integer.parseInt(req.getParameter(paramName + ".before"));
-            
+
             Object row = this.rows.get(from);
             // Add to the new location
             this.rows.add(before, row);
@@ -412,10 +413,10 @@
             // because of the previous add()
             if (before < from) from++;
             this.rows.remove(from);
-            
+
             // Needs refresh
             getForm().addWidgetUpdate(this);
-            
+
         } else {
             throw new FormsRuntimeException("Unknown action " + action + " for " + this, getLocation());
         }
@@ -521,9 +522,11 @@
      */
     public void generateWidgetLabel(String widgetId, ContentHandler contentHandler) throws SAXException {
         WidgetDefinition widgetDefinition = definition.getWidgetDefinition(widgetId);
-        if (widgetDefinition == null)
+        if (widgetDefinition == null) {
             throw new SAXException("Repeater \"" + getRequestParameterName() + "\" at " + this.getLocation()
                                    + " contains no widget with id \"" + widgetId + "\".");
+        }
+
         widgetDefinition.generateLabel(contentHandler);
     }
 
@@ -575,6 +578,7 @@
             if (pos == -1) {
                 throw new IllegalStateException("Row has currently no position");
             }
+
             if (pos != this.cachedPosition) {
                 this.cachedPosition = pos;
                 // id of a RepeaterRow is the position of the row in the list of rows.
@@ -583,7 +587,7 @@
             }
             return this.cachedId;
         }
-        
+
         public String getRequestParameterName() {
             // Get the id to check potential position change
             getId();
@@ -603,7 +607,7 @@
               ((Widget)it.next()).initialize();
             }
         }
-        
+
         public boolean validate() {
             // Validate only child widtgets, as the definition's validators are those of the parent repeater
             return widgets.validate();
@@ -663,7 +667,7 @@
         this.storage = storage;
     }
 
-	
-    
-    
+
+
+
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterAction.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterAction.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterAction.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterAction.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -17,43 +17,43 @@
 
 /**
  * An action that acts on a repeater.
- * 
+ *
  * @see RepeaterActionDefinitionBuilder
  * @version $Id$
  */
 public class RepeaterAction extends Action {
-    
+
     private Repeater repeater;
-    
+
 
     public RepeaterAction(RepeaterActionDefinition definition) {
         super(definition);
     }
-    
+
     /**
      * Get the repeater on which this action acts.
      */
     public Repeater getRepeater() {
         if (this.repeater == null) {
-            String name = ((RepeaterActionDefinition)getDefinition()).getRepeaterName();
+            String name = ((RepeaterActionDefinition) getDefinition()).getRepeaterName();
             Widget widget;
             if (name != null) {
                 // Get the corresponding sibling
-                widget = ((ContainerWidget)getParent()).getChild(name);
+                widget = ((ContainerWidget) getParent()).getChild(name);
             } else {
                 // Get the grand-parent (parent is the repeater row).
                 widget = getParent().getParent();
             }
-         
+
             if (widget == null || !(widget instanceof Repeater)) {
                 throw new RuntimeException(name != null ?
                     "Cannot find sibling repeater named '" + name + "'." :
                     "Parent widget is not a repeater");
             }
-            
+
             this.repeater = (Repeater)widget;
         }
-        
+
         return this.repeater;
     }
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinition.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -23,20 +23,20 @@
 /**
  * Abstract repeater action. Subclasses will typically just self-add an
  * event handler that will act on the repeater.
- * 
+ *
  * @see RepeaterActionDefinitionBuilder
  * @version $Id$
  */
 public abstract class RepeaterActionDefinition extends ActionDefinition {
 
     private String name = null;
-    
+
     /**
      * Builds an action whose target repeater is the parent of this widget
      */
     public RepeaterActionDefinition() {
     }
-    
+
     /**
      * Builds an action whose target is a sibling of this widget
      * @param repeaterName the name of the repeater
@@ -44,38 +44,38 @@
     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;
-    		
+
+        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()+")");
-    	}
+            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
+        }
     }
 
     public Widget createInstance() {
         return new RepeaterAction(this);
     }
-    
+
     /**
      * Get the name of the repeater on which to act. If <code>null</code>, the repeater
      * is the parent of the current widget (i.e. actions are in repeater rows). Otherwise,
      * the repeater is a sibling of the current widget.
-     * 
+     *
      * @return the repeater name (can be <code>null</code>).
      */
     public String getRepeaterName() {
         return this.name;
     }
-    
+
     //---------------------------------------------------------------------------------------------
 
     /**
@@ -98,17 +98,17 @@
          */
         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;
@@ -145,7 +145,7 @@
                 public void actionPerformed(ActionEvent event) {
                     Repeater repeater = ((RepeaterAction)event.getSource()).getRepeater();
                     for (int i=0; i<AddRowActionDefinition.this.insertRows; i++) {
-                        repeater.addRow(); 
+                        repeater.addRow();
                     }
                 }
             });
@@ -168,14 +168,14 @@
         public void initializeFrom(WidgetDefinition definition) throws Exception {
         	super.initializeFrom(definition);
 
-        	if(definition instanceof InsertRowsActionDefinition) {
-        		InsertRowsActionDefinition other = (InsertRowsActionDefinition)definition;
+            if (definition instanceof InsertRowsActionDefinition) {
+                InsertRowsActionDefinition other = (InsertRowsActionDefinition) definition;
 
-        		this.selectName = other.selectName;
+                this.selectName = other.selectName;
 
-        	} else {
-        		throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
-        	}
+            } else {
+                throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
+            }
         }
 
         public InsertRowsActionDefinition(String repeaterName, String selectWidgetName) {
@@ -204,14 +204,14 @@
             });
         }
     }
-    
 
-  
+
+
     public static class ChangePageActionDefinition extends RepeaterActionDefinition {
 
        protected int method;
-       
-       public static final int FIRST = 0; 
+
+       public static final int FIRST = 0;
        public static final int PREV = 1;
        public static final int NEXT = 2;
        public static final int LAST = 3;
@@ -222,25 +222,27 @@
          */
         public void initializeFrom(WidgetDefinition definition) throws Exception {
             super.initializeFrom(definition);
-            if(definition instanceof ChangePageActionDefinition) {
-                ChangePageActionDefinition other = (ChangePageActionDefinition)definition;
+            if (definition instanceof ChangePageActionDefinition) {
+                ChangePageActionDefinition other = (ChangePageActionDefinition) definition;
+
                 this.method = other.method;
+
             } else {
-                throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+                throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
             }
         }
 
         public ChangePageActionDefinition(String repeaterName, int m) {
             super(repeaterName);
-            
+
             this.method = m;
-            
+
             this.addActionListener(new ActionListener() {
                 public void actionPerformed(ActionEvent event) {
                     Repeater repeater = ((RepeaterAction)event.getSource()).getRepeater();
-                    
+
                     int page = repeater.getCurrentPage();
-                    
+
                     if (method == FIRST) {
                         page = 0;
                     } else if (method == PREV && page > 0) {
@@ -254,7 +256,7 @@
                     } else {
                         return;
                     }
-                    
+
                     if (repeater.isPageable()) {
                         try {
                             if (repeater.validate()) {
@@ -265,11 +267,11 @@
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
-                    } 
+                    }
                 }
             });
         }
     }
-    
-    
+
+
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterActionDefinitionBuilder.java Sat Sep 16 16:39:08 2006
@@ -56,13 +56,13 @@
     public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
         // Get the "command" attribute
         String actionCommand = DomHelper.getAttribute(widgetElement, "command", null);
-        
+
         // If unspecified, check the deprecated "action-command" deprecated attribute
         if (actionCommand == null) {
             actionCommand = DomHelper.getAttribute(widgetElement, "action-command", null);
             if (actionCommand != null) {
                 Deprecation.logger.info("The 'action-command' attribute is deprecated and replaced by 'command', at " +
-                    DomHelper.getLocation(widgetElement));
+                                        DomHelper.getLocation(widgetElement));
             }
         }
         if (actionCommand == null) {
@@ -80,7 +80,7 @@
         Element buggyOnActivate = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "on-activate", false);
         if (buggyOnActivate != null) {
             throw new Exception("Use 'on-action' instead of 'on-activate' on row-action at " +
-                DomHelper.getLocation(buggyOnActivate));
+                                DomHelper.getLocation(buggyOnActivate));
         }
 
         Iterator iter = buildEventListeners(widgetElement, "on-action", ActionListener.class).iterator();
@@ -109,16 +109,16 @@
 
         } else if ("page-first".equals(actionCommand)) {
             return new RepeaterActionDefinition.ChangePageActionDefinition(repeater, RepeaterActionDefinition.ChangePageActionDefinition.FIRST);
-        
+
         } else if ("page-prev".equals(actionCommand)) {
             return new RepeaterActionDefinition.ChangePageActionDefinition(repeater, RepeaterActionDefinition.ChangePageActionDefinition.PREV);
-        
+
         } else if ("page-next".equals(actionCommand)) {
             return new RepeaterActionDefinition.ChangePageActionDefinition(repeater, RepeaterActionDefinition.ChangePageActionDefinition.NEXT);
-        
+
         } else if ("page-last".equals(actionCommand)) {
             return new RepeaterActionDefinition.ChangePageActionDefinition(repeater, RepeaterActionDefinition.ChangePageActionDefinition.LAST);
-        
+
         } else if ("page-custom".equals(actionCommand)) {
             return new RepeaterActionDefinition.ChangePageActionDefinition(repeater, RepeaterActionDefinition.ChangePageActionDefinition.CUSTOM);
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinition.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -21,7 +21,7 @@
 
 /**
  * The {@link WidgetDefinition} part of a Repeater widget, see {@link Repeater} for more information.
- * 
+ *
  * @version $Id$
  */
 public class RepeaterDefinition extends AbstractContainerDefinition {
@@ -30,7 +30,7 @@
     private int maxSize;
     private boolean orderable;
     private RepeaterListener listener;
-    
+
     private boolean pageable=false;
     private int initialPage=0;
     private int pageSize;
@@ -42,9 +42,9 @@
         this.maxSize = maxSize;
         this.orderable = orderable;
     }
-    
-    
-    
+
+
+
     public RepeaterDefinition(int initialSize, int minSize, int maxSize, boolean selectable,boolean orderable,boolean pageable, int initialPage, int pageSize) {
 		super();
 		this.initialSize = initialSize;
@@ -64,20 +64,22 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if(definition instanceof RepeaterDefinition) {
-            RepeaterDefinition other = (RepeaterDefinition)definition;
+        if (definition instanceof RepeaterDefinition) {
+            RepeaterDefinition other = (RepeaterDefinition) definition;
+
             this.initialSize = other.initialSize;
             this.maxSize = other.maxSize;
             this.minSize = other.minSize;
+
         } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
         }
     }
 
     public Widget createInstance() {
         return new Repeater(this);
     }
-    
+
     public int getInitialSize() {
         return this.initialSize;
     }
@@ -89,22 +91,22 @@
     public int getMinSize() {
         return this.minSize;
     }
-    
+
     public boolean getOrderable() {
         return this.orderable;
     }
-    
+
     public void addRepeaterListener(RepeaterListener listener) {
         checkMutable();
         this.listener = WidgetEventMulticaster.add(this.listener, listener);
     }
-    
+
     public void fireRepeaterEvent(RepeaterEvent event) {
         if (this.listener != null) {
             this.listener.repeaterModified(event);
         }
     }
-    
+
     public boolean hasRepeaterListeners() {
         return this.listener != null;
     }
@@ -130,9 +132,9 @@
 	public int getPageSize() {
 		return pageSize;
 	}
-    
-    
-    
-    
-    
+
+
+
+
+
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RepeaterDefinitionBuilder.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -25,47 +25,47 @@
 
 /**
  * Builds {@link RepeaterDefinition}s.
- * 
+ *
  * @version $Id$
  */
 public final class RepeaterDefinitionBuilder extends AbstractContainerDefinitionBuilder {
 
     public WidgetDefinition buildWidgetDefinition(Element repeaterElement) throws Exception {
-        
+
         int initialSize = DomHelper.getAttributeAsInteger(repeaterElement, "initial-size", 0);
         int minSize = DomHelper.getAttributeAsInteger(repeaterElement, "min-size", 0);
         int maxSize = DomHelper.getAttributeAsInteger(repeaterElement, "max-size", Integer.MAX_VALUE);
 
-        // should throw error on negative values ? Just correct them for now. 
+        // should throw error on negative values ? Just correct them for now.
         if (minSize < 0) {
             throw new ConfigurationException("min-size should be positive, at " + DomHelper.getLocationObject(repeaterElement));
         }
-        
+
         if (maxSize < 0) {
             throw new ConfigurationException("max-size should be positive, at " + DomHelper.getLocationObject(repeaterElement));
         }
-        
+
         if (maxSize < minSize) {
             throw new ConfigurationException("max-size should be greater that or equal to min-size, at " + DomHelper.getLocationObject(repeaterElement));
         }
 
         // initial size is at least the min size
         initialSize = minSize > initialSize ? minSize : initialSize;
-        
+
         boolean orderable = DomHelper.getAttributeAsBoolean(repeaterElement, "orderable", false);
         boolean selectable = DomHelper.getAttributeAsBoolean(repeaterElement, "selectable", false);
 
         boolean pageable = false;
         int initialPage = 0;
         int pageSize = 0;
-        
-        Element pagesElement = DomHelper.getChildElement(repeaterElement,FormsConstants.DEFINITION_NS,"pages");
+
+        Element pagesElement = DomHelper.getChildElement(repeaterElement, FormsConstants.DEFINITION_NS, "pages");
         if (pagesElement!=null) {
             pageable = true;
             initialPage = DomHelper.getAttributeAsInteger(pagesElement, "initial", 0);
             pageSize = DomHelper.getAttributeAsInteger(pagesElement, "size", 0);
         }
-        
+
         RepeaterDefinition repeaterDefinition = new RepeaterDefinition(initialSize, minSize, maxSize, selectable, orderable, pageable,initialPage,pageSize);
         super.setupDefinition(repeaterElement, repeaterDefinition);
         setDisplayData(repeaterElement, repeaterDefinition);
@@ -74,8 +74,8 @@
         Iterator iter = buildEventListeners(repeaterElement, "on-repeater-modified", RepeaterListener.class).iterator();
         while (iter.hasNext()) {
             repeaterDefinition.addRepeaterListener((RepeaterListener)iter.next());
-        }        
-        
+        }
+
         setupContainer(repeaterElement,"widgets",repeaterDefinition);
 
         repeaterDefinition.makeImmutable();

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/RowActionDefinitionBuilder.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -24,16 +24,16 @@
 import org.w3c.dom.Element;
 
 /**
- * 
+ *
  * @version $Id$
  */
 public class RowActionDefinitionBuilder extends AbstractWidgetDefinitionBuilder {
-    
-    
+
+
     public WidgetDefinition buildWidgetDefinition(Element widgetElement) throws Exception {
         // Get the "command" attribute
         String actionCommand = DomHelper.getAttribute(widgetElement, "command", null);
-        
+
         // If unspecified, check the deprecated "action-command" deprecated attribute
         if (actionCommand == null) {
             actionCommand = DomHelper.getAttribute(widgetElement, "action-command", null);
@@ -56,7 +56,7 @@
         Element buggyOnActivate = DomHelper.getChildElement(widgetElement, FormsConstants.DEFINITION_NS, "on-activate", false);
         if (buggyOnActivate != null) {
             throw new Exception("Use 'on-action' instead of 'on-activate' on row-action at " +
-                DomHelper.getLocation(buggyOnActivate));
+                                DomHelper.getLocation(buggyOnActivate));
         }
 
         Iterator iter = buildEventListeners(widgetElement, "on-action", ActionListener.class).iterator();
@@ -67,7 +67,7 @@
         definition.makeImmutable();
         return definition;
     }
-    
+
     protected RowActionDefinition createDefinition(Element element, String actionCommand) throws Exception {
 
         if ("delete".equals(actionCommand)) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/SubmitDefinition.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -17,35 +17,35 @@
 
 /**
  * Definition for a {@link Submit}.
- * 
+ *
  * @see SubmitDefinitionBuilder
  * @version $Id$
  */
 public class SubmitDefinition extends ActionDefinition {
-    
+
     private boolean validateForm;
-    
+
     /**
      * initialize this definition with the other, sort of like a copy constructor
      */
     public void initializeFrom(WidgetDefinition definition) throws Exception {
     	super.initializeFrom(definition);
-    	
-    	if(definition instanceof SubmitDefinition) {
-    		SubmitDefinition other = (SubmitDefinition)definition;
-    		
-    		this.validateForm = other.validateForm;
-    		
+
+        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()+")");
-    	}
+            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
+        }
     }
-    
+
     public void setValidateForm(boolean validateForm) {
         checkMutable();
         this.validateForm = validateForm;
     }
-    
+
     public Widget createInstance() {
         return new Submit(this, validateForm);
     }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Union.java Sat Sep 16 16:39:08 2006
@@ -60,10 +60,11 @@
     public void initialize() {
         String caseWidgetId = definition.getCaseWidgetId();
         this.caseWidget = getParent().lookupWidget(caseWidgetId);
-        if(this.caseWidget == null) {
-            throw new RuntimeException("Could not find case widget \""
-                + caseWidgetId + "\" for union \"" + getId() + "\" at " + getLocation());
+        if (this.caseWidget == null) {
+            throw new RuntimeException("Could not find case widget \"" + caseWidgetId +
+                                       "\" for union \"" + getId() + "\" at " + getLocation());
         }
+
         ((ValueChangedListenerEnabled)caseWidget).addValueChangedListener(
             new ValueChangedListener() {
                 public void valueChanged(ValueChangedEvent event) {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UnionDefinition.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -15,28 +15,30 @@
  */
 package org.apache.cocoon.forms.formmodel;
 
-
 /**
  * The {@link WidgetDefinition} corresponding to a {@link Union} widget.
  *
  * @version $Id$
  */
 public class UnionDefinition extends AbstractContainerDefinition {
+
     private String caseWidgetId;
 
+
     /**
      * 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()+").");
-    	}
+
+        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) {
@@ -49,8 +51,7 @@
     }
 
     public Widget createInstance() {
-        Union unionWidget = new Union(this);
-        return unionWidget;
+        return new Union(this);
     }
 }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Upload.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Upload.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Upload.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/Upload.java Sat Sep 16 16:39:08 2006
@@ -87,10 +87,11 @@
         }
 
         if ((object == null) || (object instanceof Part)) {
-            this.part = (Part)object;
+            this.part = (Part) object;
         } else {
             throw new RuntimeException("The value of an upload widget must be of type " + Part.class + ".");
         }
+
         changed();
     }
 
@@ -142,7 +143,7 @@
 
         // And keep the current state if the parameter doesn't exist or is null
     }
-    
+
     private void changed() {
         if (this.hasValueChangedListeners() || this.getForm().hasFormHandler()) {
             this.getForm().addWidgetEvent(new ValueChangedEvent(this, null, this.part));
@@ -176,7 +177,7 @@
      */
     private boolean validateOversize() {
         if (!this.part.isRejected()) {
-            return true; 
+            return true;
         }
 
         // Set a validation error indicating the sizes in kbytes (rounded)
@@ -241,7 +242,7 @@
     public void removeValueChangedListener(ValueChangedListener listener) {
         this.listener = WidgetEventMulticaster.remove(this.listener, listener);
     }
-    
+
     public boolean hasValueChangedListeners() {
         return this.listener != null;
     }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/UploadDefinition.java Sat Sep 16 16:39:08 2006
@@ -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.
@@ -20,7 +20,7 @@
 
 /**
  * The definition of an upload widget.
- * 
+ *
  * @version $Id$
  */
 public class UploadDefinition extends AbstractWidgetDefinition {
@@ -44,15 +44,15 @@
     public void initializeFrom(WidgetDefinition definition) throws Exception {
         super.initializeFrom(definition);
 
-        if(definition instanceof UploadDefinition) {
-            UploadDefinition other = (UploadDefinition)definition;
+        if (definition instanceof UploadDefinition) {
+            UploadDefinition other = (UploadDefinition) definition;
 
             this.required = other.required;
             this.mimeTypes = other.mimeTypes;
             this.listener = WidgetEventMulticaster.add(this.listener, other.listener);
 
         } else {
-            throw new Exception("Definition to inherit from is not of the right type! (at "+getLocation()+")");
+            throw new Exception("Definition to inherit from is not of the right type! (at " + getLocation() + ")");
         }
     }
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java Sat Sep 16 16:39:08 2006
@@ -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
@@ -46,7 +46,7 @@
         this.containerDefinition = definition;
         wasHere = false;
     }
-    
+
     public int size() {
     	return widgetDefinitions.size();
     }
@@ -78,7 +78,7 @@
     }
 
     public WidgetDefinition getWidgetDefinition(String id) {
-        return (WidgetDefinition)widgetDefinitionsById.get(id);
+        return (WidgetDefinition) widgetDefinitionsById.get(id);
     }
 
     public void resolve(List parents, WidgetDefinition parent) throws Exception {
@@ -87,16 +87,17 @@
             this.definitionsIt = widgetDefinitions.listIterator();
             parents.add(containerDefinition);
             while (this.definitionsIt.hasNext()) {
-                WidgetDefinition widgetDefinition = (WidgetDefinition)this.definitionsIt.next();
+                WidgetDefinition widgetDefinition = (WidgetDefinition) this.definitionsIt.next();
                 // ClassDefinition's get resolved by NewDefinition rather than here.
                 if (!(widgetDefinition instanceof ClassDefinition)) {
                     if (widgetDefinition instanceof NewDefinition) {
                         // Remove NewDefinition in preparation for its referenced class of widget definitions to be added.
                         this.definitionsIt.remove();
-                        ((NewDefinition)widgetDefinition).resolve(parents, containerDefinition);
+                        ((NewDefinition) widgetDefinition).resolve(parents, containerDefinition);
                     } else {
-                        if (widgetDefinition instanceof ContainerDefinition)
-                            ((ContainerDefinition)widgetDefinition).resolve(parents, containerDefinition);
+                        if (widgetDefinition instanceof ContainerDefinition) {
+                            ((ContainerDefinition) widgetDefinition).resolve(parents, containerDefinition);
+                        }
                     }
                 }
             }
@@ -108,53 +109,61 @@
             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 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 + ")");
+                    }
+
+                    throw new Exception("Container: Non-terminating recursion detected in widget definition: " +
+                                        parent.getId() + " (" + location + ")");
                 }
             }
         }
     }
- 
+
     public void createWidget(Widget parent, String id) {
-        WidgetDefinition widgetDefinition = (WidgetDefinition)widgetDefinitionsById.get(id);
+        WidgetDefinition widgetDefinition = (WidgetDefinition) widgetDefinitionsById.get(id);
         if (widgetDefinition == null) {
             throw new RuntimeException(containerDefinition.getId() + ": WidgetDefinition \"" + id +
-                    "\" does not exist (" + containerDefinition.getLocation() + ")");
+                                       "\" does not exist (" + containerDefinition.getLocation() + ")");
         }
+
         Widget widget = widgetDefinition.createInstance();
-        if (widget != null)
-            ((ContainerWidget)parent).addChild(widget);
+        if (widget != null) {
+            ((ContainerWidget) parent).addChild(widget);
+        }
     }
 
     public void createWidgets(Widget parent) {
-        Iterator definitionsIt = widgetDefinitions.iterator();
-        while (definitionsIt.hasNext()) {
-            WidgetDefinition widgetDefinition = (WidgetDefinition)definitionsIt.next();
+        Iterator i = widgetDefinitions.iterator();
+        while (i.hasNext()) {
+            WidgetDefinition widgetDefinition = (WidgetDefinition) i.next();
             Widget widget = widgetDefinition.createInstance();
-            if (widget != null)
-                ((ContainerWidget)parent).addChild(widget);
+            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);
-            
+            // 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();
+            Iterator i = widgetDefinitions.iterator();
+            while (i.hasNext()) {
+                ((WidgetDefinition) i.next()).checkCompleteness();
             }
             wasHere = false;
         }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/Library.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/Library.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/Library.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/Library.java Sat Sep 16 16:39:08 2006
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -38,110 +38,109 @@
 public class Library {
 
 	public static final String SEPARATOR = ":";
-	
-	
+
 	// managed instances
 	protected ServiceSelector widgetDefinitionBuilderSelector;
-	
+
 	// own references
-	protected LibraryManager manager = null;
-	
+	protected LibraryManager manager;
+
 	// 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 String sourceURI;
 	protected WidgetDefinitionBuilderContext context;
-	
-	public Library(LibraryManager lm) {
+
+
+    public Library(LibraryManager lm) {
 		manager = lm;
 		context = new WidgetDefinitionBuilderContext();
 		context.setLocalLibrary(this);
 	}
-	
+
 	public void setSourceURI(String uri) {
 		sourceURI = uri;
 	}
-	public String getSourceURI() {
+
+    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;
+        Iterator i = this.inclusions.values().iterator();
+        while (i.hasNext()) {
+            Dependency dep = (Dependency) i.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 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 
-	{
+    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);
-		}
-		
-	}
-	
+            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(SEPARATOR)>-1) {
-			String[] parts = StringUtils.split(key,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);
-		}
-	}
-	
+
+        if (key.indexOf(SEPARATOR) > -1) {
+            String[] parts = StringUtils.split(key, 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, FormsConstants.DEFINITION_NS, "widgets", true);
+        sourceURI = LocationAttributes.getURI(libraryElement);
+        Element widgetsElement = DomHelper.getChildElement(libraryElement, FormsConstants.DEFINITION_NS, "widgets", true);
         // All child elements of the widgets element are widgets
         Element[] widgetElements = DomHelper.getChildElements(widgetsElement, FormsConstants.DEFINITION_NS);
         for (int i = 0; i < widgetElements.length; i++) {
@@ -149,75 +148,74 @@
             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!");
-		
-		// let the definition know where it comes from
-		definition.setEnclosingLibrary(this);
-		
-		// add def to our list of defs
-		definitions.put(definition.getId(),definition);
-		manager.debug(this+": Put definition with id: "+definition.getId());
-	}
-	
+        if (definition == null) {
+            return;
+        }
+
+        if (definitions.containsKey(definition.getId())) {
+            throw new LibraryException("Library already contains a widget with this ID!");
+        }
+
+        // let the definition know where it comes from
+        definition.setEnclosingLibrary(this);
+
+        // add def to our list of defs
+        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;
+        WidgetDefinitionBuilder builder;
         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)
+
+        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 
+	 * Encapsulates a uri to designate an import plus a timestamp so previously reloaded
 	 */
 	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);
-			}
-			
+                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);
+            }
 		}
 	}
-	
+
 }

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java?view=diff&rev=446974&r1=446973&r2=446974
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java (original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/java/org/apache/cocoon/forms/formmodel/library/LibraryManager.java Sat Sep 16 16:39:08 2006
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -15,26 +15,23 @@
  */
 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$
  *
+ * @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);
 }



Mime
View raw message