Class InstantiatingNullHandler

  extended by com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler
All Implemented Interfaces:

public class InstantiatingNullHandler
extends java.lang.Object
implements NullHandler

Provided that the key ReflectionContextState.CREATE_NULL_OBJECTS is in the action context with a value of true (this key is set only during the execution of the ParametersInterceptor), OGNL expressions that have caused a NullPointerException will be temporarily stopped for evaluation while the system automatically tries to solve the null references by automatically creating the object.

The following rules are used when handling null references:

For example, if a form element has a text field named and the expression person evaluates to null, then this class will be invoked. Because the person expression evaluates to a Person class, a new Person is created and assigned to the null reference. Finally, the name is set on that object and the overall effect is that the system automatically created a Person object for you, set it by calling setUsers() and then finally called getUsers().setName() as you would typically expect.
Field Summary
static java.lang.String CREATE_NULL_OBJECTS
          Deprecated. Use ReflectionContextState.CREATE_NULL_OBJECTS instead
Constructor Summary
Method Summary
 java.lang.Object nullMethodResult(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.Object target, java.lang.String methodName, java.lang.Object[] args)
          Method called on target returned null.
 java.lang.Object nullPropertyValue(java.util.Map<java.lang.String,java.lang.Object> context, java.lang.Object target, java.lang.Object property)
          Property in target evaluated to null.
 void setObjectFactory(ObjectFactory fac)
 void setObjectTypeDeterminer(ObjectTypeDeterminer det)
 void setReflectionProvider(ReflectionProvider prov)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final java.lang.String CREATE_NULL_OBJECTS
Deprecated. Use ReflectionContextState.CREATE_NULL_OBJECTS instead
See Also:
Constant Field Values
Constructor Detail


public InstantiatingNullHandler()
Method Detail


public void setObjectTypeDeterminer(ObjectTypeDeterminer det)


public void setReflectionProvider(ReflectionProvider prov)


public void setObjectFactory(ObjectFactory fac)


public java.lang.Object nullMethodResult(java.util.Map<java.lang.String,java.lang.Object> context,
                                         java.lang.Object target,
                                         java.lang.String methodName,
                                         java.lang.Object[] args)
Description copied from interface: NullHandler
Method called on target returned null.

Specified by:
nullMethodResult in interface NullHandler


public java.lang.Object nullPropertyValue(java.util.Map<java.lang.String,java.lang.Object> context,
                                          java.lang.Object target,
                                          java.lang.Object property)
Description copied from interface: NullHandler
Property in target evaluated to null. Property can be a constant String property name or a DynamicSubscript.

Specified by:
nullPropertyValue in interface NullHandler

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.