Class UifServletRequestDataBinder

java.lang.Object
org.springframework.validation.DataBinder
org.springframework.web.bind.WebDataBinder
org.springframework.web.bind.ServletRequestDataBinder
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

    Fields
    Modifier and Type
    Field
    Description
    protected static final org.apache.logging.log4j.Logger
     

    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

    Constructors
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Set<String>
    assembleAutoLinkingPaths(String path, org.kuali.rice.krad.data.util.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>
    extractAutoLinkListTargets(String autoLinkingPath, List<?> targetList)
    For the list object indicated for linking, iterates through the modified paths and finds paths that match entries in the list, and if found adds an auto link target.
    protected List<org.kuali.rice.krad.web.bind.UifServletRequestDataBinder.AutoLinkTarget>
    extractAutoLinkMapTargets(String autoLinkingPath, Map<?,?> targetMap)
    For the map object indicated for linking, iterates through the modified paths and finds paths that match entries in the map, and if found adds an auto link target.
    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.
    org.kuali.rice.krad.data.DataObjectService
     
    protected org.springframework.validation.AbstractPropertyBindingResult
    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
    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)
     
    void
    Allows for a custom binding result class.
    void
    Disallows direct field access for Kuali
    boolean
     
    boolean
     
    void
    setAutoLinking(boolean autoLinking)
     
    void
    setDataObjectService(org.kuali.rice.krad.data.DataObjectService dataObjectService)
     

    Methods inherited from class org.springframework.web.bind.ServletRequestDataBinder

    addBindValues, closeNoCatch

    Methods inherited from class org.springframework.web.bind.WebDataBinder

    adaptEmptyArrayIndices, bindMultipart, checkFieldDefaults, checkFieldMarkers, doBind, getEmptyValue, getEmptyValue, getFieldDefaultPrefix, getFieldMarkerPrefix, isBindEmptyMultipartFiles, setBindEmptyMultipartFiles, setFieldDefaultPrefix, setFieldMarkerPrefix

    Methods inherited from class org.springframework.validation.DataBinder

    addCustomFormatter, addCustomFormatter, addCustomFormatter, addValidators, applyPropertyValues, bind, checkAllowedFields, checkRequiredFields, close, convertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessary, createBeanPropertyBindingResult, createDirectFieldBindingResult, findCustomEditor, getAllowedFields, getAutoGrowCollectionLimit, getBindingErrorProcessor, getBindingResult, getConversionService, getDisallowedFields, getObjectName, getPropertyAccessor, getPropertyEditorRegistry, getRequiredFields, getSimpleTypeConverter, getTarget, getTypeConverter, getValidator, getValidators, isAllowed, isAutoGrowNestedPaths, isIgnoreInvalidFields, isIgnoreUnknownFields, registerCustomEditor, registerCustomEditor, replaceValidators, setAllowedFields, setAutoGrowCollectionLimit, setAutoGrowNestedPaths, setBindingErrorProcessor, setConversionService, setDisallowedFields, 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 Details

    • LOG

      protected static final org.apache.logging.log4j.Logger LOG
  • Constructor Details

    • UifServletRequestDataBinder

      public UifServletRequestDataBinder(Object target)
    • UifServletRequestDataBinder

      public UifServletRequestDataBinder(Object target, String name)
  • Method Details

    • 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, org.kuali.rice.krad.data.util.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 UifServletRequestDataBinder.AutoLinkTarget objects which contain an object to be linked and which properties on that object were modified during this data binding execution
    • extractAutoLinkMapTargets

      protected List<org.kuali.rice.krad.web.bind.UifServletRequestDataBinder.AutoLinkTarget> extractAutoLinkMapTargets(String autoLinkingPath, Map<?,?> targetMap)
      For the map object indicated for linking, iterates through the modified paths and finds paths that match entries in the map, and if found adds an auto link target.
      Parameters:
      autoLinkingPath - path configured for auto linking
      targetMap - map object for the linking path
      Returns:
      List of auto linking targets to process
    • extractAutoLinkListTargets

      protected List<org.kuali.rice.krad.web.bind.UifServletRequestDataBinder.AutoLinkTarget> extractAutoLinkListTargets(String autoLinkingPath, List<?> targetList)
      For the list object indicated for linking, iterates through the modified paths and finds paths that match entries in the list, and if found adds an auto link target.
      Parameters:
      autoLinkingPath - path configured for auto linking
      targetList - list object for the linking path
      Returns:
      List of auto linking targets to process
    • 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 org.kuali.rice.krad.data.DataObjectService getDataObjectService()
    • setDataObjectService

      public void setDataObjectService(org.kuali.rice.krad.data.DataObjectService dataObjectService)