com.opensymphony.xwork.util
Class InstantiatingNullHandler

java.lang.Object
  extended by com.opensymphony.xwork.util.InstantiatingNullHandler
All Implemented Interfaces:
ognl.NullHandler

public class InstantiatingNullHandler
extends Object
implements ognl.NullHandler

Provided that the key 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 person.name 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 setPerson() and then finally called getPerson().setName() as you would typically expect.
Field Summary
static String CREATE_NULL_OBJECTS
           
 
Constructor Summary
InstantiatingNullHandler()
           
 
Method Summary
 Object nullMethodResult(Map context, Object target, String methodName, Object[] args)
           
 Object nullPropertyValue(Map context, Object target, Object property)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATE_NULL_OBJECTS

public static final String CREATE_NULL_OBJECTS
See Also:
Constant Field Values
Constructor Detail

InstantiatingNullHandler

public InstantiatingNullHandler()
Method Detail

nullMethodResult

public Object nullMethodResult(Map context,
                               Object target,
                               String methodName,
                               Object[] args)
Specified by:
nullMethodResult in interface ognl.NullHandler

nullPropertyValue

public Object nullPropertyValue(Map context,
                                Object target,
                                Object property)
Specified by:
nullPropertyValue in interface ognl.NullHandler

WebWork Project Page