Class SessionContext

  • All Implemented Interfaces:
    Router

    public class SessionContext
    extends java.lang.Object
    implements Router
    • Field Detail

      • onDestroyed

        public final Event<org.teamapps.dto.UiSessionClosingReason> onDestroyed
      • executionDecorators

        public final ExecutionDecoratorStack executionDecorators
        Decorators around all executions inside this SessionContext. These will be invoked when the Thread is already bound to the SessionContext, so SessionContext.current() will return this instance.
    • Constructor Detail

      • SessionContext

        public SessionContext​(UiSession uiSession,
                              java.util.concurrent.ExecutorService sessionExecutor,
                              ClientInfo clientInfo,
                              SessionConfiguration sessionConfiguration,
                              jakarta.servlet.http.HttpSession httpSession,
                              UxServerContext serverContext,
                              org.teamapps.icons.SessionIconProvider iconProvider,
                              java.lang.String navigationPathPrefix,
                              jakarta.ws.rs.ext.ParamConverterProvider navigationParamConverterProvider)
    • Method Detail

      • getCurrentLocation

        public Location getCurrentLocation()
      • navigateBack

        public void navigateBack​(int steps)
      • navigateForward

        public void navigateForward​(int steps)
      • createSubRouter

        public Router createSubRouter​(java.lang.String relativePath)
        Specified by:
        createSubRouter in interface Router
      • pushNavigationHistoryState

        public void pushNavigationHistoryState​(java.lang.String pathWithQueryParams,
                                               boolean fireEvent)
        Pushes a new entry (URL) to the browser's navigation history without reloading the site. See JavaScript API.

        This method may or may not fire an onNavigationStateChange event, depending on the value of the fireEvent parameter. Both cases are useful:

        • When the user does some action that changes the state of the UI that needs to be reflected in the URL (say changing a table filter parameter) the corresponding change will most likely already have been applied to the UI. So in such a case it does not make sense to fire the event.
        • In the case that the user clicks on a LinkButton (or similar action) which will navigate to some completely different parts of the UI, it makes sense that the event is triggered, so the routing to that UI can happen.

        Note that the onNavigationStateChange event will not be fired asynchronously since it will be triggered by the client (browser!) in order to guarantee the correct sequence of events. For example, if the user presses a navigation button at the same time as this method is invoked, which one was first needs to be consistent on the client and server side.

        Parameters:
        pathWithQueryParams - May also be a complete URL, but this is not recommended, since the origin needs to stay the same.
        fireEvent - Indicates whether an onNavigationStateChange event should be fired as a reaction of this invocation.
      • setTranslationProvider

        public void setTranslationProvider​(TranslationProvider translationProvider)
      • addIconBundle

        public void addIconBundle​(IconBundle iconBundle)
      • getIcon

        public org.teamapps.icons.Icon<?,​?> getIcon​(java.lang.String key)
      • getULocale

        public com.ibm.icu.util.ULocale getULocale()
      • getLocale

        public java.util.Locale getLocale()
      • setLocale

        public void setLocale​(java.util.Locale locale)
      • setULocale

        public void setULocale​(com.ibm.icu.util.ULocale locale)
      • getLocalized

        public java.lang.String getLocalized​(java.lang.String key,
                                             java.lang.Object... parameters)
      • isActive

        public boolean isActive()
      • isDestroyed

        public boolean isDestroyed()
      • destroy

        public void destroy()
      • queueCommand

        public <RESULT> void queueCommand​(org.teamapps.dto.UiCommand<RESULT> command,
                                          java.util.function.Consumer<RESULT> resultCallback)
      • queueCommand

        public void queueCommand​(org.teamapps.dto.UiCommand<?> command)
      • getClientInfo

        public ClientInfo getClientInfo()
      • getHttpSession

        public jakarta.servlet.http.HttpSession getHttpSession()
      • createFileLink

        public java.lang.String createFileLink​(java.io.File file)
      • createResourceLink

        public java.lang.String createResourceLink​(Resource resource,
                                                   java.lang.String uniqueIdentifier)
      • getBinaryResource

        public Resource getBinaryResource​(int resourceId)
      • getUploadedFileByUuid

        public java.io.File getUploadedFileByUuid​(java.lang.String uuid)
      • registerTemplates

        public void registerTemplates​(java.util.Map<java.lang.String,​Template> templates)
      • getTemplate

        public Template getTemplate​(java.lang.String id)
      • runWithContext

        public java.util.concurrent.CompletableFuture<java.lang.Void> runWithContext​(java.lang.Runnable runnable)
      • runWithContext

        public java.util.concurrent.CompletableFuture<java.lang.Void> runWithContext​(java.lang.Runnable runnable,
                                                                                     boolean forceEnqueue)
        Parameters:
        runnable -
        forceEnqueue - No synchronous execution! Enqueue this at the end of this SessionContext's work queue.
      • runWithContext

        public <R> java.util.concurrent.CompletableFuture<R> runWithContext​(java.util.concurrent.Callable<R> runnable)
      • runWithContext

        public <R> java.util.concurrent.CompletableFuture<R> runWithContext​(java.util.concurrent.Callable<R> callable,
                                                                            boolean forceEnqueue)
      • addExecutionDecorator

        public void addExecutionDecorator​(ExecutionDecorator decorator,
                                          boolean outer)
        Adds a decorator that gets invoked whenever a Thread is bound to this SessionContext. The decorator will be called right after the Thread is bound to this SessionContext, so SessionContext.current() will return this instance.
        Parameters:
        decorator -
        outer - Whether to add this decorator as outermost or innermost execution wrapper.
      • removeExecutionDecorator

        public void removeExecutionDecorator​(ExecutionDecorator decorator)
        Removes the specified execution decorator.
      • clearExecutionDecorators

        public void clearExecutionDecorators()
        Removes all decorators.
      • showPopupAtCurrentMousePosition

        public void showPopupAtCurrentMousePosition​(Popup popup)
      • showPopup

        public void showPopup​(Popup popup)
      • getTimeZone

        public java.time.ZoneId getTimeZone()
      • getIconProvider

        public org.teamapps.icons.SessionIconProvider getIconProvider()
      • setDefaultStyleForIconClass

        public <I extends org.teamapps.icons.Icon<I,​S>,​S> void setDefaultStyleForIconClass​(java.lang.Class<I> iconClass,
                                                                                                       S defaultStyle)
      • resolveIcon

        public java.lang.String resolveIcon​(org.teamapps.icons.Icon icon)
      • registerClientObject

        public void registerClientObject​(ClientObject clientObject)
      • unregisterClientObject

        public void unregisterClientObject​(ClientObject clientObject)
      • getClientObject

        public ClientObject getClientObject​(java.lang.String clientObjectId)
      • createResourceLink

        public java.lang.String createResourceLink​(Resource resource)
      • showWindow

        public void showWindow​(Window window,
                               int animationDuration)
      • download

        public void download​(Resource resource,
                             java.lang.String downloadFileName)
      • download

        public void download​(java.io.File file,
                             java.lang.String downloadFileName)
      • download

        public void download​(java.lang.String url,
                             java.lang.String downloadFileName)
      • registerBackgroundImage

        public void registerBackgroundImage​(java.lang.String id,
                                            java.lang.String image,
                                            java.lang.String blurredImage)
      • setBackgroundImage

        public void setBackgroundImage​(java.lang.String id,
                                       int animationDuration)
      • showDefaultBackground

        public void showDefaultBackground​(int animationDuration)
      • setBackgroundColor

        public void setBackgroundColor​(org.teamapps.common.format.Color color,
                                       int animationDuration)
      • exitFullScreen

        public void exitFullScreen()
      • addRootComponent

        public void addRootComponent​(java.lang.String containerElementSelector,
                                     Component component)
      • addRootPanel

        public void addRootPanel​(java.lang.String containerElementSelector,
                                 Component rootPanel)
      • addRootPanel

        public RootPanel addRootPanel​(java.lang.String containerElementSelector)
      • addRootPanel

        public RootPanel addRootPanel()
      • addClientToken

        public void addClientToken​(java.lang.String token)
      • removeClientToken

        public void removeClientToken​(java.lang.String token)
      • clearClientTokens

        public void clearClientTokens()
      • showNotification

        public void showNotification​(org.teamapps.icons.Icon icon,
                                     java.lang.String caption)
      • showNotification

        public void showNotification​(org.teamapps.icons.Icon icon,
                                     java.lang.String caption,
                                     java.lang.String description)
      • showNotification

        public void showNotification​(org.teamapps.icons.Icon icon,
                                     java.lang.String caption,
                                     java.lang.String description,
                                     boolean dismissable,
                                     int displayTimeInMillis,
                                     boolean showProgress)
      • setSessionExpiredWindow

        public void setSessionExpiredWindow​(Window sessionExpiredWindow)
      • setSessionErrorWindow

        public void setSessionErrorWindow​(Window sessionErrorWindow)
      • setSessionTerminatedWindow

        public void setSessionTerminatedWindow​(Window sessionTerminatedWindow)
      • createDefaultSessionMessageWindow

        public static Window createDefaultSessionMessageWindow​(java.lang.String title,
                                                               java.lang.String message,
                                                               java.lang.String refreshButtonCaption,
                                                               java.lang.String cancelButtonCaption)
      • requestWakeLock

        public java.util.concurrent.CompletableFuture<WakeLock> requestWakeLock()
      • goToUrl

        public void goToUrl​(java.lang.String url,
                            boolean blankPage)
      • setFavicon

        public void setFavicon​(org.teamapps.icons.Icon<?,​?> icon)
      • setFavicon

        public void setFavicon​(Resource resource)
      • setFavicon

        public void setFavicon​(java.lang.String url)
      • setTitle

        public void setTitle​(java.lang.String title)
      • setGlobalKeyEventsEnabled

        public void setGlobalKeyEventsEnabled​(boolean unmodified,
                                              boolean modifiedWithAltKey,
                                              boolean modifiedWithCtrlKey,
                                              boolean modifiedWithMetaKey,
                                              boolean includeRepeats,
                                              boolean keyDown,
                                              boolean keyUp)
      • getSessionId

        public java.lang.String getSessionId()
      • handleStaticEvent

        public void handleStaticEvent​(org.teamapps.dto.UiEvent event)
      • reApplyRouters

        public void reApplyRouters()
      • getAsUiSessionListenerInternal

        public UiSessionListener getAsUiSessionListenerInternal()
      • setName

        public void setName​(java.lang.String name)
      • getName

        public java.lang.String getName()
      • getRoutingParamConverterProvider

        public jakarta.ws.rs.ext.ParamConverterProvider getRoutingParamConverterProvider()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object