Author: gvanmatre
Date: Sat Jul 28 09:56:48 2007
New Revision: 560569

URL: http://svn.apache.org/viewvc?view=rev&rev=560569
Log:
When the shale-tiger Property annotation is evaluated, a nifty type converter 
is used to coerce the source data type to the target data type.  This utility 
reuses existing JSF converters outside the context of rendering.  It assumes a 
FacesContext and UIViewRoot.  I removed the requirement that a UIViewRoot is 
needed.  Since we are using converters for outside of the component tree, we 
just need a object that extends UIComponent (SHALE-406).

Modified:
    
shale/framework/branches/SHALE_1_0_X/shale-core/src/main/java/org/apache/shale/util/ConverterHelper.java

Modified: 
shale/framework/branches/SHALE_1_0_X/shale-core/src/main/java/org/apache/shale/util/ConverterHelper.java
URL: 
http://svn.apache.org/viewvc/shale/framework/branches/SHALE_1_0_X/shale-core/src/main/java/org/apache/shale/util/ConverterHelper.java?view=diff&rev=560569&r1=560568&r2=560569
==============================================================================
--- 
shale/framework/branches/SHALE_1_0_X/shale-core/src/main/java/org/apache/shale/util/ConverterHelper.java
 (original)
+++ 
shale/framework/branches/SHALE_1_0_X/shale-core/src/main/java/org/apache/shale/util/ConverterHelper.java
 Sat Jul 28 09:56:48 2007
@@ -18,6 +18,7 @@
 package org.apache.shale.util;
 
 import javax.faces.FacesException;
+import javax.faces.component.UIViewRoot;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
@@ -65,7 +66,13 @@
         if (String.class == type) {
             return value;
         }
-        return converter(context, type).getAsObject(context, 
context.getViewRoot(), value);
+
+        UIViewRoot root = context.getViewRoot();
+        if (root == null) {
+            root = new UIViewRoot();
+        }
+        
+        return converter(context, type).getAsObject(context, root, value);
 
     }
 
@@ -88,7 +95,12 @@
         } else if ((String.class == type) && (value instanceof String)) {
             return (String) value;
         }
-        return converter(context, type).getAsString(context, 
context.getViewRoot(), value);
+        UIViewRoot root = context.getViewRoot();
+        if (root == null) {
+            root = new UIViewRoot();
+        }
+
+        return converter(context, type).getAsString(context, root, value);
 
     }
 


Reply via email to