Class UiRequestUtil
java.lang.Object
io.vertigo.ui.impl.springmvc.util.UiRequestUtil
Utility class for accessing and manipulating request associated attributes.
- Author:
- npiedeloup
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidPersist the UiMessageStack until next request.static ViewContextRetrieves the current ViewContext.static <O> Optional<O> getRequestScopedAttribute(String name, Class<O> valueClass) Retrieves a request-scoped attribute as an Optional.static voidInvalidates the current HTTP session, effectively logging out the user.static booleanDetermines if delayUiMessageStack have been called in the current request.static booleanisJsonRequest(jakarta.servlet.http.HttpServletRequest request) Checks if the given HTTP request is a JSON request based on the "Accept" header.static io.vertigo.vega.webservice.validation.UiMessageStackObtains the current UiMessageStack.static voidRestores the UiMessageStack from the session to the request and removes it from the session.static voidsetCurrentUiMessageStack(io.vertigo.vega.webservice.validation.UiMessageStack uiMessageStack) Sets the UiMessageStack for the current request.static voidsetRequestScopedAttribute(String name, Object value) Sets a request-scoped attribute.static voidStores the current UiMessageStack in the session.
-
Field Details
-
UI_MESSAGE_STACK_ATTRIBUTE_NAME
- See Also:
-
-
Method Details
-
invalidateHttpSession
public static void invalidateHttpSession()Invalidates the current HTTP session, effectively logging out the user. -
getCurrentViewContext
Retrieves the current ViewContext.- Returns:
- the current ViewContext
-
obtainCurrentUiMessageStack
public static io.vertigo.vega.webservice.validation.UiMessageStack obtainCurrentUiMessageStack()Obtains the current UiMessageStack.- Returns:
- the current UiMessageStack
-
setCurrentUiMessageStack
public static void setCurrentUiMessageStack(io.vertigo.vega.webservice.validation.UiMessageStack uiMessageStack) Sets the UiMessageStack for the current request.- Parameters:
uiMessageStack- the UiMessageStack to set
-
storeUiMessageStackInSession
public static void storeUiMessageStackInSession()Stores the current UiMessageStack in the session. The stack is kept for max 3 minutes. -
restoreUiMessageStackFromSession
public static void restoreUiMessageStackFromSession()Restores the UiMessageStack from the session to the request and removes it from the session. -
setRequestScopedAttribute
Sets a request-scoped attribute.- Parameters:
name- the name of the attributevalue- the value of the attribute
-
getRequestScopedAttribute
Retrieves a request-scoped attribute as an Optional.- Type Parameters:
O- the type of the attribute- Parameters:
name- the name of the attributevalueClass- the class of the attribute- Returns:
- an Optional containing the attribute value, or an empty Optional if not found
-
delayUiMessageStack
public static void delayUiMessageStack()Persist the UiMessageStack until next request. Useful for example in the "close modale and refresh parent" pattern, to display messages from the popin in the parent. -
isDelayUiMessageStack
public static boolean isDelayUiMessageStack()Determines if delayUiMessageStack have been called in the current request.- Returns:
- true if delayUiMessageStack have been called in the current request.
-
isJsonRequest
public static boolean isJsonRequest(jakarta.servlet.http.HttpServletRequest request) Checks if the given HTTP request is a JSON request based on the "Accept" header.- Parameters:
request- the HTTP request- Returns:
- true if the request is a JSON request, false otherwise
-