org.kuali.rice.krad.web.bind
Class UifServletRequestDataBinder

java.lang.Object
  extended by org.springframework.validation.DataBinder
      extended by org.springframework.web.bind.WebDataBinder
          extended by org.springframework.web.bind.ServletRequestDataBinder
              extended by org.kuali.rice.krad.web.bind.UifServletRequestDataBinder
All Implemented Interfaces:
org.springframework.beans.PropertyEditorRegistry, org.springframework.beans.TypeConverter

public class UifServletRequestDataBinder
extends org.springframework.web.bind.ServletRequestDataBinder

Override of ServletRequestDataBinder in order to hook in the UifBeanPropertyBindingResult which instantiates a custom BeanWrapperImpl, and to initialize the view.

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

Field Summary
protected static org.apache.log4j.Logger LOG
           
 
Fields inherited from class org.springframework.web.bind.WebDataBinder
DEFAULT_FIELD_DEFAULT_PREFIX, DEFAULT_FIELD_MARKER_PREFIX
 
Fields inherited from class org.springframework.validation.DataBinder
DEFAULT_AUTO_GROW_COLLECTION_LIMIT, DEFAULT_OBJECT_NAME, logger
 
Constructor Summary
UifServletRequestDataBinder(Object target)
           
UifServletRequestDataBinder(Object target, String name)
           
 
Method Summary
protected  Set<String> assembleAutoLinkingPaths(String path, Link autoLink)
          A helper method which simply assembles a set of property paths for the given Link annotation which should be auto linked.
 void bind(javax.servlet.ServletRequest request)
          Calls UifFormBase.preBind(HttpServletRequest), Performs data binding from servlet request parameters to the form, initializes view object, then calls UifFormBase.postBind(javax.servlet.http.HttpServletRequest)
protected  Set<String> determineRootAutoLinkingPaths(Class<?> rootObjectType, String path, Set<Class<?>> scanned)
          Determines the root property paths relative to the given root object type against which to perform automatic linking.
protected  void executeAutomaticLinking(javax.servlet.ServletRequest request, UifFormBase form)
          Performs automatic reference linking of the given form based on the properties on the form for which linking is enabled.
protected  List<org.kuali.rice.krad.web.bind.UifServletRequestDataBinder.AutoLinkTarget> extractAutoLinkTargets(Set<String> autoLinkingPaths)
          Uses the binding result on this data binder to determine the targets on the form that automatic linking should be performed against.
 DataObjectService getDataObjectService()
           
protected  org.springframework.validation.AbstractPropertyBindingResult getInternalBindingResult()
          Allows for the setting attributes to use to find the data dictionary data from Kuali
protected  View getViewByType(javax.servlet.ServletRequest request, UifFormBase form)
          Attempts to get a view instance by looking for a view type name in the request or the form and querying that view type with the request parameters
protected  View getViewFromPreviousModel(UifFormBase form)
          Attempts to get a view instance based on the view id stored on the form (which might not be populated from the request but remaining from session)
 ViewService getViewService()
           
 void initBeanPropertyAccess()
          Allows for a custom binding result class.
 void initDirectFieldAccess()
          Disallows direct field access for Kuali
 boolean isAutoLinking()
           
 boolean isChangeTracking()
           
 void setAutoLinking(boolean autoLinking)
           
 void setDataObjectService(DataObjectService dataObjectService)
           
 
Methods inherited from class org.springframework.web.bind.ServletRequestDataBinder
addBindValues, closeNoCatch
 
Methods inherited from class org.springframework.web.bind.WebDataBinder
bindMultipart, bindMultipartFiles, checkFieldDefaults, checkFieldMarkers, doBind, getEmptyValue, getFieldDefaultPrefix, getFieldMarkerPrefix, isBindEmptyMultipartFiles, setBindEmptyMultipartFiles, setFieldDefaultPrefix, setFieldMarkerPrefix
 
Methods inherited from class org.springframework.validation.DataBinder
addValidators, applyPropertyValues, bind, checkAllowedFields, checkRequiredFields, close, convertIfNecessary, convertIfNecessary, convertIfNecessary, findCustomEditor, getAllowedFields, getAutoGrowCollectionLimit, getBindingErrorProcessor, getBindingResult, getConversionService, getDisallowedFields, getErrors, getObjectName, getPropertyAccessor, getPropertyEditorRegistry, getRequiredFields, getSimpleTypeConverter, getTarget, getTypeConverter, getValidator, getValidators, isAllowed, isAutoGrowNestedPaths, isIgnoreInvalidFields, isIgnoreUnknownFields, registerCustomEditor, registerCustomEditor, replaceValidators, setAllowedFields, setAutoGrowCollectionLimit, setAutoGrowNestedPaths, setBindingErrorProcessor, setConversionService, setDisallowedFields, setExtractOldValueForEditor, setIgnoreInvalidFields, setIgnoreUnknownFields, setMessageCodesResolver, setRequiredFields, setValidator, validate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG
Constructor Detail

UifServletRequestDataBinder

public UifServletRequestDataBinder(Object target)

UifServletRequestDataBinder

public UifServletRequestDataBinder(Object target,
                                   String name)
Method Detail

initBeanPropertyAccess

public void initBeanPropertyAccess()
Allows for a custom binding result class.

Overrides:
initBeanPropertyAccess in class org.springframework.validation.DataBinder
See Also:
DataBinder.initBeanPropertyAccess()

getInternalBindingResult

protected org.springframework.validation.AbstractPropertyBindingResult getInternalBindingResult()
Allows for the setting attributes to use to find the data dictionary data from Kuali

Overrides:
getInternalBindingResult in class org.springframework.validation.DataBinder
See Also:
DataBinder.getInternalBindingResult()

initDirectFieldAccess

public void initDirectFieldAccess()
Disallows direct field access for Kuali

Overrides:
initDirectFieldAccess in class org.springframework.validation.DataBinder
See Also:
DataBinder.initDirectFieldAccess()

bind

public void bind(javax.servlet.ServletRequest request)
Calls UifFormBase.preBind(HttpServletRequest), Performs data binding from servlet request parameters to the form, initializes view object, then calls UifFormBase.postBind(javax.servlet.http.HttpServletRequest)

The view is initialized by first looking for the viewId parameter in the request. If found, the view is retrieved based on this id. If the id is not present, then an attempt is made to find a view by type. In order to retrieve a view based on type, the view request parameter viewTypeName must be present. If all else fails and the viewId is populated on the form (could be populated from a previous request), this is used to retrieve the view.

Overrides:
bind in class org.springframework.web.bind.ServletRequestDataBinder
Parameters:
request - - HTTP Servlet Request instance

executeAutomaticLinking

protected void executeAutomaticLinking(javax.servlet.ServletRequest request,
                                       UifFormBase form)
Performs automatic reference linking of the given form based on the properties on the form for which linking is enabled.

Linking will only be performed if change tracking and auto linking are enabled on this data binder.

Parameters:
request - request instance
form - form instance against which to perform automatic linking

determineRootAutoLinkingPaths

protected Set<String> determineRootAutoLinkingPaths(Class<?> rootObjectType,
                                                    String path,
                                                    Set<Class<?>> scanned)
Determines the root property paths relative to the given root object type against which to perform automatic linking.

This will be determined based on the presence of Link annotations on the given root object type. This method is invoked recursively as it walks the class structure looking for Link annotations. It uses the path and scanned arguments to keep track of how deep into the structure the scanning is and to prevent infinite recursion.

Parameters:
rootObjectType - the root object type from which to perform the scan for auto-linking paths
path - the current property path relative to the original root object type at which the scan began, if null then we are scanning from the root-most object type. Each recursive call of this method will append a new property to this path
scanned - used to track classes that have already been scanned and prevent infinite recursion
Returns:
a set of property paths that should be auto linked

assembleAutoLinkingPaths

protected Set<String> assembleAutoLinkingPaths(String path,
                                               Link autoLink)
A helper method which simply assembles a set of property paths for the given Link annotation which should be auto linked.

Parameters:
path - the property path from the top-most root class to where the Link annotation was found during the scan
autoLink - the Link annotation which is being processed
Returns:
a Set of auto linking paths based on the given path parameter, plus the path(s) defined on the Link annotation

extractAutoLinkTargets

protected List<org.kuali.rice.krad.web.bind.UifServletRequestDataBinder.AutoLinkTarget> extractAutoLinkTargets(Set<String> autoLinkingPaths)
Uses the binding result on this data binder to determine the targets on the form that automatic linking should be performed against.

Only those property paths for which auto linking is enabled and which were actually modified during the execution of this data binding will be returned from this method.

Parameters:
autoLinkingPaths - a set of paths relative to the form class for which auto-linking has been enabled
Returns:
a list of AutoLinkTarget objects which contain an object to be linked and which properties on that object were modified during this data binding execution

getViewByType

protected View getViewByType(javax.servlet.ServletRequest request,
                             UifFormBase form)
Attempts to get a view instance by looking for a view type name in the request or the form and querying that view type with the request parameters

Parameters:
request - request instance to pull parameters from
form - form instance to pull values from
Returns:
View instance if found or null

getViewFromPreviousModel

protected View getViewFromPreviousModel(UifFormBase form)
Attempts to get a view instance based on the view id stored on the form (which might not be populated from the request but remaining from session)

Parameters:
form - form instance to pull view id from
Returns:
View instance associated with form's view id or null if id or view not found

isChangeTracking

public boolean isChangeTracking()

isAutoLinking

public boolean isAutoLinking()

setAutoLinking

public void setAutoLinking(boolean autoLinking)

getViewService

public ViewService getViewService()

getDataObjectService

public DataObjectService getDataObjectService()

setDataObjectService

public void setDataObjectService(DataObjectService dataObjectService)


Copyright © 2005–2014 The Kuali Foundation. All rights reserved.