Commits

Anonymous committed 4749f4a

support to handle nulls as well as a default conversion type.

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@82e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits 2881aac

Comments (0)

Files changed (1)

File src/java/com/opensymphony/xwork/util/OgnlValueStack.java

 
     CompoundRoot root;
     transient Map context;
+    Class defaultType;
 
     //~ Constructors ///////////////////////////////////////////////////////////
 
 
     public Object findValue(String expr) {
         try {
+            if (expr == null) {
+                return null;
+            }
+
+            if (defaultType != null) {
+                return findValue(expr, defaultType);
+            }
+
             return Ognl.getValue(OgnlUtil.compile(expr), context, root);
         } catch (OgnlException e) {
             return null;
 
     public Object findValue(String expr, Class asType) {
         try {
+            if (expr == null) {
+                return null;
+            }
+
             return Ognl.getValue(OgnlUtil.compile(expr), context, root, asType);
         } catch (OgnlException e) {
             return null;
         return root.size();
     }
 
+    public void setDefaultType(Class defaultType) {
+        this.defaultType = defaultType;
+    }
+
     private void setRoot(CompoundRoot compoundRoot) {
         this.root = compoundRoot;
         this.context = Ognl.createDefaultContext(this.root, accessor, XWorkConverter.getInstance());