org.kuali.rice.krad.uif.util
Class ViewModelUtils

java.lang.Object
  extended by org.kuali.rice.krad.uif.util.ViewModelUtils

public class ViewModelUtils
extends Object

Provides methods for getting property values, types, and paths within the context of a View

The view provides a special map named 'abstractTypeClasses' that indicates concrete classes that should be used in place of abstract property types that are encountered on the object graph. This classes takes into account that map while dealing with properties. e.g. suppose we have propertyPath 'document.name' on the form, with the type of the document property set to the interface Document. Using class introspection we would get back the interface type for document and this would not be able to get the property type for name. Using the view map, we can replace document with a concrete class and then use it to get the name property

Author:
Kuali Rice Team (rice.collab@kuali.org)

Constructor Summary
ViewModelUtils()
           
 
Method Summary
static Class<?> getObjectClassForMetadata(View view, Object model, String propertyPath)
          Determines the associated type for the property within the View context
static Class<?> getParentObjectClassForMetadata(View view, DataField field)
          Determines the associated type for the property within the View context
static Class<?> getParentObjectClassForMetadata(View view, Object model, DataField field)
          Determines the associated type for the property within the View context
static Object getParentObjectForMetadata(View view, Object model, DataField field)
          Retrieves the parent object if it exists or attempts to create a new instance
static String getParentObjectPath(DataField field)
          Gets the parent object path of the data field
static Class<?> getPropertyTypeByClassAndView(View view, String propertyPath)
          Determines the associated type for the property within the View context
static String getStringValFromPVs(org.springframework.beans.PropertyValues propertyValues, String propertyName)
          Helper method for getting the string value of a property from a PropertyValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewModelUtils

public ViewModelUtils()
Method Detail

getPropertyTypeByClassAndView

public static Class<?> getPropertyTypeByClassAndView(View view,
                                                     String propertyPath)
Determines the associated type for the property within the View context

Property path is full path to property from the View Form class. The abstract type classes map configured on the View will be consulted for any entries that match the property path. If the property path given contains a partial match to an abstract class (somewhere on path is an abstract class), the property type will be retrieved based on the given concrete class to use and the part of the path remaining. If no matching entry is found, standard reflection is used to get the type

Parameters:
view - - view instance providing the context (abstract map)
propertyPath - - full path to property to retrieve type for (relative to the form class)
Returns:
Class type of property in model, or Null if type could not be determined
See Also:
View.getObjectPathToConcreteClassMapping()

getParentObjectPath

public static String getParentObjectPath(DataField field)
Gets the parent object path of the data field

Parameters:
field -
Returns:
String parent object path

getParentObjectClassForMetadata

public static Class<?> getParentObjectClassForMetadata(View view,
                                                       DataField field)
Determines the associated type for the property within the View context

The abstract type classes map configured on the View will be consulted for any entries that match the property path. If the parent object path for the given field contains a partial match to an abstract class (somewhere on path is an abstract class), the property type will be retrieved based on the given concrete class to use and the part of the path remaining. If no matching entry is found, standard reflection is used to get the type

Parameters:
view - - view instance providing the context (abstract map)
field - - field to retrieve type for
Returns:
Class type of property in model, or Null if type could not be determined
See Also:
View.getObjectPathToConcreteClassMapping()

getParentObjectClassForMetadata

public static Class<?> getParentObjectClassForMetadata(View view,
                                                       Object model,
                                                       DataField field)
Determines the associated type for the property within the View context

If the parent object instance is not null, get the class through it. Otherwise, use the following logic: The abstract type classes map configured on the View will be consulted for any entries that match the property path. If the parent object path for the given field contains a partial match to an abstract class (somewhere on path is an abstract class), the property type will be retrieved based on the given concrete class to use and the part of the path remaining. If no matching entry is found, standard reflection is used to get the type

Parameters:
view - - view instance providing the context (abstract map)
model - - object model
field - - field to retrieve type for
Returns:
Class the class of the object instance if not null or the type of property in model, or Null if type could not be determined
See Also:
View.getObjectPathToConcreteClassMapping()

getObjectClassForMetadata

public static Class<?> getObjectClassForMetadata(View view,
                                                 Object model,
                                                 String propertyPath)
Determines the associated type for the property within the View context

If the parent object instance is not null, get the class through it. Otherwise, use the following logic: The abstract type classes map configured on the View will be consulted for any entries that match the property path. If the parent object path for the given field contains a partial match to an abstract class (somewhere on path is an abstract class), the property type will be retrieved based on the given concrete class to use and the part of the path remaining. If no matching entry is found, standard reflection is used to get the type

Parameters:
view - - view instance providing the context (abstract map)
model - - object model
propertyPath - - full path to property to retrieve type for (relative to the form class)
Returns:
Class the class of the object instance if not null or the type of property in model, or Null if type could not be determined
See Also:
View.getObjectPathToConcreteClassMapping()

getParentObjectForMetadata

public static Object getParentObjectForMetadata(View view,
                                                Object model,
                                                DataField field)
Retrieves the parent object if it exists or attempts to create a new instance

Parameters:
view - - view instance providing the context (abstract map)
model - - object model
field - - field to retrieve type for
Returns:
Class the class of the object instance if not null or the type of property in model, or Null if type could not be determined
See Also:
View.getObjectPathToConcreteClassMapping()

getStringValFromPVs

public static String getStringValFromPVs(org.springframework.beans.PropertyValues propertyValues,
                                         String propertyName)
Helper method for getting the string value of a property from a PropertyValues

Parameters:
propertyValues - - property values instance to pull from
propertyName - - name of property whose value should be retrieved
Returns:
String value for property or null if property was not found


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.