org.springframework.web.bind.support

Class DefaultSessionAttributeStore

  • java.lang.Object
    • org.springframework.web.bind.support.DefaultSessionAttributeStore
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void cleanupAttribute(WebRequest request, java.lang.String attributeName)
      Clean up the specified attribute in the backend session.
      protected java.lang.String getAttributeNameInSession(WebRequest request, java.lang.String attributeName)
      Calculate the attribute name in the backend session.
      java.lang.Object retrieveAttribute(WebRequest request, java.lang.String attributeName)
      Retrieve the specified attribute from the backend session.
      void setAttributeNamePrefix(java.lang.String attributeNamePrefix)
      Specify a prefix to use for the attribute names in the backend session.
      void storeAttribute(WebRequest request, java.lang.String attributeName, java.lang.Object attributeValue)
      Store the supplied attribute in the backend session.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultSessionAttributeStore

        public DefaultSessionAttributeStore()
    • Method Detail

      • setAttributeNamePrefix

        public void setAttributeNamePrefix(@Nullable
                                           java.lang.String attributeNamePrefix)
        Specify a prefix to use for the attribute names in the backend session.

        Default is to use no prefix, storing the session attributes with the same name as in the model.

      • storeAttribute

        public void storeAttribute(WebRequest request,
                                   java.lang.String attributeName,
                                   java.lang.Object attributeValue)
        Description copied from interface: SessionAttributeStore
        Store the supplied attribute in the backend session.

        Can be called for new attributes as well as for existing attributes. In the latter case, this signals that the attribute value may have been modified.

        Specified by:
        storeAttribute in interface SessionAttributeStore
        Parameters:
        request - the current request
        attributeName - the name of the attribute
        attributeValue - the attribute value to store
      • retrieveAttribute

        @Nullable
        public java.lang.Object retrieveAttribute(WebRequest request,
                                                            java.lang.String attributeName)
        Description copied from interface: SessionAttributeStore
        Retrieve the specified attribute from the backend session.

        This will typically be called with the expectation that the attribute is already present, with an exception to be thrown if this method returns null.

        Specified by:
        retrieveAttribute in interface SessionAttributeStore
        Parameters:
        request - the current request
        attributeName - the name of the attribute
        Returns:
        the current attribute value, or null if none
      • cleanupAttribute

        public void cleanupAttribute(WebRequest request,
                                     java.lang.String attributeName)
        Description copied from interface: SessionAttributeStore
        Clean up the specified attribute in the backend session.

        Indicates that the attribute name will not be used anymore.

        Specified by:
        cleanupAttribute in interface SessionAttributeStore
        Parameters:
        request - the current request
        attributeName - the name of the attribute
      • getAttributeNameInSession

        protected java.lang.String getAttributeNameInSession(WebRequest request,
                                                             java.lang.String attributeName)
        Calculate the attribute name in the backend session.

        The default implementation simply prepends the configured "attributeNamePrefix", if any.

        Parameters:
        request - the current request
        attributeName - the name of the attribute
        Returns:
        the attribute name in the backend session