Class AttributesControllerAdvice
- java.lang.Object
-
- uk.ac.warwick.dcs.sherlock.module.web.controlleradvice.AttributesControllerAdvice
-
@ControllerAdvice public class AttributesControllerAdvice extends java.lang.Object
Declares ModelAttributes for all controllers
-
-
Constructor Summary
Constructors Constructor Description AttributesControllerAdvice()
-
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 requestsvoid
addIsPrinting(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request)
Adds an "is printing" boolean to the attribute of all requestsvoid
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 casesvoid
addMessage(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request)
Adds the msg parameter to the attributes of all requestsvoid
checkLoaded()
Checks that the Spring server has finished initialising and throws an error if a user attempts to load a page before it has finishedAccountWrapper
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 attributesboolean
isAjax(javax.servlet.http.HttpServletRequest request)
Checks whether the current request is ajax or notboolean
isPrinting(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request)
Checks whether or not the request is attempting to print
-
-
-
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 attributesauthentication
- 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 attributesrequest
- 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 attributesrequest
- 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 attributesrequest
- 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 attributesrequest
- 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
-
-