Class AttributesControllerAdvice


  • @ControllerAdvice
    public class AttributesControllerAdvice
    extends java.lang.Object
    Declares ModelAttributes for all controllers
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addIsAjax​(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request)
      Adds an "is ajax" boolean to the attributes of all requests
      void addIsPrinting​(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request)
      Adds an "is printing" boolean to the attribute of all requests
      void addJsUrl​(org.springframework.ui.Model model)
      Sets the javascript url to the standard version when running the webdev profile and the minified in all other cases
      void addMessage​(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request)
      Adds the msg parameter to the attributes of all requests
      void checkLoaded()
      Checks that the Spring server has finished initialising and throws an error if a user attempts to load a page before it has finished
      AccountWrapper getAccount​(org.springframework.ui.Model model, org.springframework.security.core.Authentication authentication)
      Gets the account of the currently logged in user using the authentication details and adds it to the model attributes
      boolean isAjax​(javax.servlet.http.HttpServletRequest request)
      Checks whether the current request is ajax or not
      boolean isPrinting​(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request)
      Checks whether or not the request is attempting to print
      • Methods inherited from class java.lang.Object

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

      • AttributesControllerAdvice

        public AttributesControllerAdvice()
    • Method Detail

      • checkLoaded

        @ModelAttribute
        public void checkLoaded()
                         throws SpringNotInitialised
        Checks that the Spring server has finished initialising and throws an error if a user attempts to load a page before it has finished
        Throws:
        SpringNotInitialised - if the server is still starting up
      • getAccount

        @ModelAttribute("account")
        public AccountWrapper getAccount​(org.springframework.ui.Model model,
                                         org.springframework.security.core.Authentication authentication)
        Gets the account of the currently logged in user using the authentication details and adds it to the model attributes
        Parameters:
        model - holder for model attributes
        authentication - the authentication class
        Returns:
        the account wrapper if logged in, or an empty wrapper if not
      • addMessage

        @ModelAttribute
        public void addMessage​(org.springframework.ui.Model model,
                               javax.servlet.http.HttpServletRequest request)
        Adds the msg parameter to the attributes of all requests
        Parameters:
        model - holder for model attributes
        request - the http request information
      • addIsAjax

        @ModelAttribute
        public void addIsAjax​(org.springframework.ui.Model model,
                              javax.servlet.http.HttpServletRequest request)
        Adds an "is ajax" boolean to the attributes of all requests
        Parameters:
        model - holder for model attributes
        request - the http request information
      • addIsPrinting

        @ModelAttribute
        public void addIsPrinting​(org.springframework.ui.Model model,
                                  javax.servlet.http.HttpServletRequest request)
        Adds an "is printing" boolean to the attribute of all requests
        Parameters:
        model - holder for model attributes
        request - the http request information
      • isPrinting

        @ModelAttribute("isPrinting")
        public boolean isPrinting​(org.springframework.ui.Model model,
                                  javax.servlet.http.HttpServletRequest request)
        Checks whether or not the request is attempting to print
        Parameters:
        model - holder for model attributes
        request - the http request information
        Returns:
        whether or not the request is attempting to print
      • isAjax

        @ModelAttribute("isAjax")
        public boolean isAjax​(javax.servlet.http.HttpServletRequest request)
        Checks whether the current request is ajax or not
        Parameters:
        request - the http request information
        Returns:
        whether or not the request is an ajax one
      • addJsUrl

        @ModelAttribute
        public void addJsUrl​(org.springframework.ui.Model model)
        Sets the javascript url to the standard version when running the webdev profile and the minified in all other cases
        Parameters:
        model - holder for model attributes