You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2005/09/20 16:06:28 UTC

svn commit: r290455 - in /cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms: FormsRuntimeException.java formmodel/AbstractWidget.java generation/JXMacrosHelper.java

Author: sylvain
Date: Tue Sep 20 07:06:24 2005
New Revision: 290455

URL: http://svn.apache.org/viewcvs?rev=290455&view=rev
Log:
Start adding located exceptions

Added:
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/FormsRuntimeException.java   (with props)
Modified:
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
    cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java

Added: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/FormsRuntimeException.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/FormsRuntimeException.java?rev=290455&view=auto
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/FormsRuntimeException.java (added)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/FormsRuntimeException.java Tue Sep 20 07:06:24 2005
@@ -0,0 +1,44 @@
+/*
+ * Copyright 1999-200( 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;
+
+import org.apache.cocoon.util.location.LocatedRuntimeException;
+import org.apache.cocoon.util.location.Location;
+
+/**
+ * An exception raised when some runtime error occurs in form handling. This is a
+ * located exception, which points to the relevant element declaration.
+ * 
+ * @version $Id$
+ */
+public class FormsRuntimeException extends LocatedRuntimeException {
+
+    public FormsRuntimeException(String message, Location location) {
+        super(message, location);
+    }
+
+    public FormsRuntimeException(String message, Throwable cause, Location location) throws LocatedRuntimeException {
+        super(message, cause, location);
+    }
+
+    public FormsRuntimeException(String message, Throwable cause) throws LocatedRuntimeException {
+        super(message, cause);
+    }
+
+    public FormsRuntimeException(String message) {
+        super(message);
+    }
+}

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

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

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java?rev=290455&r1=290454&r2=290455&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/formmodel/AbstractWidget.java Tue Sep 20 07:06:24 2005
@@ -532,6 +532,8 @@
         if (last != -1) {
             className = className.substring(last+1);
         }
-        return className + "-" + getRequestParameterName();
+        
+        String name = getRequestParameterName();
+        return name.length() == 0 ? className : className + " '" + getRequestParameterName() + "'";
     }
 }

Modified: cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java?rev=290455&r1=290454&r2=290455&view=diff
==============================================================================
--- cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java (original)
+++ cocoon/blocks/forms/trunk/java/org/apache/cocoon/forms/generation/JXMacrosHelper.java Tue Sep 20 07:06:24 2005
@@ -25,6 +25,7 @@
 
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.forms.Constants;
+import org.apache.cocoon.forms.FormsRuntimeException;
 import org.apache.cocoon.forms.formmodel.Form;
 import org.apache.cocoon.forms.formmodel.Repeater;
 import org.apache.cocoon.forms.formmodel.Widget;
@@ -85,7 +86,7 @@
         if(returnForm != null) {
             return returnForm;
         }
-        throw new NullPointerException("The template cannot find a form object");
+        throw new FormsRuntimeException("The template cannot find a form object");
     }
 
     public void startForm(Form form, Map attributes) throws SAXException {
@@ -142,7 +143,7 @@
         boolean inUpdatedTemplate = ((Boolean)widgetStack.peek(1)).booleanValue();
         Widget widget = parent.lookupWidget(path);
         if (widget == null) {
-            throw new IllegalArgumentException("Widget '" + parent + "' has no child named '" + path + "'");
+            throw new FormsRuntimeException(parent + " has no child named '" + path + "'", parent.getLocation());
         }
 
         String id = widget.getFullName();
@@ -234,8 +235,9 @@
 
     public boolean pushRepeater(String path) throws SAXException {
         boolean result = pushWidget(path, true);
-        if (!(peekWidget() instanceof Repeater)) {
-            throw new IllegalArgumentException("Widget " + peekWidget() + " is not a repeater");
+        Widget w = peekWidget();
+        if (!(w instanceof Repeater)) {
+            throw new FormsRuntimeException(w + " is not a repeater", w.getLocation());
         }
         return result;
     }
@@ -252,8 +254,7 @@
         if (result != null) {
             return result;
         }
-        throw new IllegalArgumentException("Widget '" + currentWidget +
-                                           "' has no child named '" + path + "'");
+        throw new FormsRuntimeException(currentWidget + " has no child named '" + path + "'", currentWidget.getLocation());
     }
 
     private Repeater getRepeater(Widget currentWidget, String id) {
@@ -261,7 +262,7 @@
         if (child instanceof Repeater) {
             return (Repeater)child;
         }
-        throw new IllegalArgumentException("Widget '" + child + "' is not a repeater");
+        throw new FormsRuntimeException(child + " is not a repeater", child.getLocation());
     }
 
     /**
@@ -338,7 +339,7 @@
         Object result = this.classes == null ? null : this.classes.get(id);
 
         if (result == null) {
-            throw new IllegalArgumentException("No class '" + id + "' has been defined.");
+            throw new FormsRuntimeException("No class '" + id + "' has been defined.");
         } 
         return result;
     }