incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmatth...@apache.org
Subject svn commit: r1043365 - in /incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher: ./ context/ view/display/ view/edit/ view/form/ view/simple/
Date Wed, 08 Dec 2010 11:40:25 GMT
Author: rmatthews
Date: Wed Dec  8 11:40:24 2010
New Revision: 1043365

URL: http://svn.apache.org/viewvc?rev=1043365&view=rev
Log:
Improved error handing in pages and allow types to be tested

Modified:
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractElementProcessor.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/InputForm.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
    incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractElementProcessor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractElementProcessor.java?rev=1043365&r1=1043364&r2=1043365&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractElementProcessor.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/AbstractElementProcessor.java
Wed Dec  8 11:40:24 2010
@@ -20,7 +20,25 @@
 
 package org.apache.isis.viewer.scimpi.dispatcher;
 
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
 public abstract class AbstractElementProcessor implements ElementProcessor, Names {
+
+    /**
+     * Return the Class for the class specified in the type attribute.  
+     */
+    protected Class<?> forClass(Request request) { 
+        Class<?> cls = null; 
+        String className = request.getOptionalProperty(TYPE);
+        if (className != null) {
+            try {
+                cls = Class.forName(className);
+            } catch (ClassNotFoundException e) {
+                throw new ScimpiException("No class for " + className, e);
+            }
+        }
+        return cls;
+    }
     /*
     protected static final String COLLECTION = "collection";
     protected static final String CONFIRM = "confirm";

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java?rev=1043365&r1=1043364&r2=1043365&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/Dispatcher.java
Wed Dec  8 11:40:24 2010
@@ -333,6 +333,8 @@ public class Dispatcher {
         errorView.endTable();
         errorView.footer();
         writer.close();
+        
+        requestContext.clearTransientVariables();
     }
 
     public void init(String dir) {

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java?rev=1043365&r1=1043364&r2=1043365&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/RequestContext.java
Wed Dec  8 11:40:24 2010
@@ -667,5 +667,9 @@ public abstract class RequestContext {
 
     public void appendDebugTrace(String line) { 
         debugTrace.append(line); 
+    }
+
+    public void clearTransientVariables() {
+        objectMapping.endSession();
     } 
 }

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java?rev=1043365&r1=1043364&r2=1043365&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
Wed Dec  8 11:40:24 2010
@@ -43,6 +43,9 @@ public class GetField extends AbstractEl
         String id = request.getOptionalProperty(OBJECT);
         String fieldName = request.getRequiredProperty(FIELD);
         ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+        if (object == null) {
+            throw new ScimpiException("No object to get field for: " + fieldName + " - "
+ id);
+        }
         ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
         if (field == null) {
             throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullName());

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java?rev=1043365&r1=1043364&r2=1043365&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/edit/FieldFactory.java
Wed Dec  8 11:40:24 2010
@@ -79,12 +79,17 @@ public class FieldFactory {
         }
 
         if (optionsForParameter != null) {
-            int noOptions = optionsForParameter.length;
+            int noOptions = optionsForParameter.length + (field.isRequired() ? 0 : 1);
             String[] optionValues = new String[noOptions];
             String[] optionTitles = new String[noOptions];
-            for (int j = 0; j < noOptions; j++) {
-                optionValues[j] = getValue(context, optionsForParameter[j]);
-                optionTitles[j] = optionsForParameter[j].titleString();
+            if (!field.isRequired()) {
+                optionValues[0] = "null";
+                optionTitles[0] = "[not set]";
+            }
+            for (int j = 0; j < optionsForParameter.length; j++) {
+                int i = j + (field.isRequired() ? 0 : 1);
+                optionValues[i] = getValue(context, optionsForParameter[j]);
+                optionTitles[i] = optionsForParameter[j].titleString();
             }
             field.setOptions(optionTitles, optionValues);
         }

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/InputForm.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/InputForm.java?rev=1043365&r1=1043364&r2=1043365&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/InputForm.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/form/InputForm.java
Wed Dec  8 11:40:24 2010
@@ -159,7 +159,7 @@ public class InputForm {
         String[] ids = field.getOptionValues();
         int length = options.length;
         for (int i = 0; i < length; i++) {
-            String selectedSegment = ids[i].equals(field.getValue()) ? " selected=\"selected\""
: "";
+            String selectedSegment = field.getValue() == null || ids[i].equals(field.getValue())
? " selected=\"selected\"" : "";
             str.append("    <option value=\"" + ids[i] + "\"" + selectedSegment + ">"
+ options[i] + "</option>\n");
         }
         if (field.getType()  == InputField.TEXT) {

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java?rev=1043365&r1=1043364&r2=1043365&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/AbstractConditionalBlock.java
Wed Dec  8 11:40:24 2010
@@ -140,13 +140,22 @@ public abstract class AbstractConditiona
             return;
         }
 
+
         String persistent = request.getOptionalProperty("persistent");
         if (persistent != null) {
             ObjectAdapter object = (ObjectAdapter) request.getContext().getMappedObjectOrResult(persistent);
             processTags(object.isPersistent(), request);
             return;
         }
-        
+
+        String type = request.getOptionalProperty(TYPE);
+        if (type != null) {
+            ObjectAdapter object = (ObjectAdapter) request.getContext().getMappedObjectOrResult(id);
+            Class<?> cls = forClass(request);
+            boolean hasType = cls == null || cls.isAssignableFrom(object.getObject().getClass());

+            processTags(hasType, request);
+            return;
+        }
         
         if (request.isPropertySpecified("empty")) {
             if (request.isPropertySet("empty")) {

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java?rev=1043365&r1=1043364&r2=1043365&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java
(original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/simple/InitializeFromResult.java
Wed Dec  8 11:40:24 2010
@@ -61,19 +61,6 @@ public class InitializeFromResult extend
         } 
     } 
 
-    private Class<?> forClass(Request request) { 
-        Class<?> cls = null; 
-        String className = request.getOptionalProperty(TYPE);
-        if (className != null) {
-            try {
-                cls = Class.forName(className);
-            } catch (ClassNotFoundException e) {
-                throw new ScimpiException("No class for " + className, e);
-            }
-        }
-        return cls;
-    }
-
     private void disallowSourceAndDefault(Request request) { 
         if (request.getOptionalProperty(DEFAULT) != null && request.getOptionalProperty(OBJECT)
!= null) { 
             throw new ScimpiException("Cannot specify both " + OBJECT + " and " + DEFAULT
+ " for the " + getName() + " element");     



Mime
View raw message