Package ninja.session

Class FlashScopeImpl

  • All Implemented Interfaces:
    FlashScope

    public class FlashScopeImpl
    extends Object
    implements FlashScope
    Default FlashScope implementation.
    • Constructor Detail

      • FlashScopeImpl

        @Inject
        public FlashScopeImpl​(NinjaProperties ninjaProperties)
    • Method Detail

      • init

        public void init​(Context context)
        Description copied from interface: FlashScope
        Intended for use by implementations only. Initializes the FlashScope from the context. Ninja will call this when a new request is being handled.
        Specified by:
        init in interface FlashScope
        Parameters:
        context - The Ninja context
      • save

        public void save​(Context context)
        Description copied from interface: FlashScope
        Intended for use by implementations only. Saves the FlashScope to the context. Will write/delete cookies, etc. Ninja will call this when a request will be completed.
        Specified by:
        save in interface FlashScope
        Parameters:
        context - The Ninja context
      • now

        public void now​(String key,
                        String value)
        Description copied from interface: FlashScope
        Puts the key and value into only the "current" flash data. Will NOT be written as a cookie and will only exist for the current request. Accessible via ${flash.key} in your html templating engine.
        Specified by:
        now in interface FlashScope
        Parameters:
        key - The flash key
        value - The i18n key used to retrieve value of that message OR an already translated message (if your template engine supports it)
        See Also:
        If you need the value for both the current and next request
      • get

        public String get​(String key)
        Description copied from interface: FlashScope
        Gets a value if its in either the "current" or "outgoing" flash data.
        Specified by:
        get in interface FlashScope
        Parameters:
        key - The flash key
        Returns:
        The flash value or null if none exists by that key
      • remove

        public boolean remove​(String key)
        Description copied from interface: FlashScope
        Removes a value completely from both "current" and "outgoing" flash data.
        Specified by:
        remove in interface FlashScope
        Parameters:
        key - The flash key
        Returns:
        True if removed or false if it didn't exist
      • contains

        public boolean contains​(String key)
        Description copied from interface: FlashScope
        Checks if the key exists in the "current" flash data.
        Specified by:
        contains in interface FlashScope
        Parameters:
        key - The flash key
        Returns:
        True if the key exists or false if it doesn't
      • put

        public void put​(String key,
                        String value)
        Description copied from interface: FlashScope
        Puts the key and value into both "current" and "outgoing" flash data. Will be written as a cookie and available in the current and next request. If you only need the value in your current request its a good idea to use the now() method instead so you can eliminate the possibility of showing unexpected flash messages on the next request :-).
        Specified by:
        put in interface FlashScope
        Parameters:
        key - The flash key
        value - The i18n key used to retrieve value of that message OR an already translated message (if your template engine supports it)
        See Also:
        If you only need the value in your current request.
      • error

        public void error​(String value)
        Description copied from interface: FlashScope
        Same as calling flash.put("error", "your value");. The value will be added to both "current" and "outgoing" flash data.
        Specified by:
        error in interface FlashScope
        Parameters:
        value - The i18n key used to retrieve value of that message OR an already translated message (if your template engine supports it)
      • success

        public void success​(String value)
        Description copied from interface: FlashScope
        Same as calling flash.put("success", "your value");. The value will be added to both "current" and "outgoing" flash data.
        Specified by:
        success in interface FlashScope
        Parameters:
        value - The i18n key used to retrieve value of that message OR an already translated message (if your template engine supports it)
      • keep

        public void keep​(String key)
        Description copied from interface: FlashScope
        Will copy the "current" flash data specified by the key into the "outgoing" flash data.
        Specified by:
        keep in interface FlashScope
        Parameters:
        key - The flash key
      • keep

        public void keep()
        Description copied from interface: FlashScope
        Copies all "current" flash data into the "outgoing" flash data.
        Specified by:
        keep in interface FlashScope
      • clearCurrentFlashCookieData

        public void clearCurrentFlashCookieData()
        Description copied from interface: FlashScope
        Clears all "current" flash data. If you need to ensure all "current" and "outgoing" flash data is deleted then call this as well as discard().
        Specified by:
        clearCurrentFlashCookieData in interface FlashScope