Class SessionContext

java.lang.Object
org.teamapps.ux.session.SessionContext

public class SessionContext extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • getCurrentLocation

      public Location getCurrentLocation()
    • getBaseRouter

      public Router getBaseRouter()
    • getRouter

      public Router getRouter(String pathPrefix)
    • updateNavigationHistoryState

      public void updateNavigationHistoryState()
    • pushNavigationHistoryState

      public void pushNavigationHistoryState(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.
    • replaceNavigationHistoryState

      public void replaceNavigationHistoryState(String pathWithQueryParams, boolean fireEvent)
      Same as pushNavigationHistoryState(String, boolean), except that it replaces the current browser history entry (URL). See JavaScript API.
      See Also:
    • changeNavigationHistoryState

      public void changeNavigationHistoryState(String pathWithQueryParams, boolean fireEvent, NavigationHistoryOperation operation)
      See Also:
    • current

      public static SessionContext current()
    • currentOrNull

      public static SessionContext currentOrNull()
    • setTranslationProvider

      public void setTranslationProvider(TranslationProvider translationProvider)
    • getTranslationProvider

      public TranslationProvider getTranslationProvider()
    • addIconBundle

      public void addIconBundle(IconBundle iconBundle)
    • getIcon

      public Icon<?,?> getIcon(String key)
    • getULocale

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

      public Locale getLocale()
    • setLocale

      public void setLocale(Locale locale)
    • setULocale

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

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

      public boolean isActive()
    • getState

      public UiSessionState getState()
    • isDestroyed

      public boolean isDestroyed()
    • destroy

      public void destroy()
    • queueCommand

      public <RESULT> void queueCommand(UiCommand<RESULT> command, Consumer<RESULT> resultCallback)
    • queueCommand

      public void queueCommand(UiCommand<?> command)
    • getClientInfo

      public ClientInfo getClientInfo()
    • getHttpSession

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

      public ClientBackPressureInfo getClientBackPressureInfo()
    • createFileLink

      public String createFileLink(File file)
    • createResourceLink

      public String createResourceLink(Resource resource, String uniqueIdentifier)
    • getBinaryResource

      public Resource getBinaryResource(int resourceId)
    • getUploadedFileByUuid

      public File getUploadedFileByUuid(String uuid)
    • registerTemplate

      public TemplateReference registerTemplate(String id, Template template)
    • registerTemplates

      public void registerTemplates(Map<String,Template> templates)
    • getTemplate

      public Template getTemplate(String id)
    • runWithContext

      public CompletableFuture<Void> runWithContext(Runnable runnable)
    • runWithContext

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

      public <R> CompletableFuture<R> runWithContext(Callable<R> runnable)
    • runWithContext

      public <R> CompletableFuture<R> runWithContext(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.
    • getConfiguration

      public SessionConfiguration getConfiguration()
    • setConfiguration

      public void setConfiguration(SessionConfiguration config)
    • showPopupAtCurrentMousePosition

      public void showPopupAtCurrentMousePosition(Popup popup)
    • showPopup

      public void showPopup(Popup popup)
    • getTimeZone

      public ZoneId getTimeZone()
    • getIconProvider

      public SessionIconProvider getIconProvider()
    • setDefaultStyleForIconClass

      public <I extends Icon<I, S>, S> void setDefaultStyleForIconClass(Class<I> iconClass, S defaultStyle)
    • resolveIcon

      public String resolveIcon(Icon icon)
    • registerClientObject

      public void registerClientObject(ClientObject clientObject)
    • unregisterClientObject

      public void unregisterClientObject(ClientObject clientObject)
    • getClientObject

      public ClientObject getClientObject(String clientObjectId)
    • createResourceLink

      public String createResourceLink(Resource resource)
    • showWindow

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

      public void download(Resource resource)
    • download

      public void download(Resource resource, String downloadFileName)
    • download

      public void download(File file, String downloadFileName)
    • download

      public void download(String url, String downloadFileName)
    • registerBackgroundImage

      public void registerBackgroundImage(String id, String image, String blurredImage)
    • setBackgroundImage

      public void setBackgroundImage(String id, int animationDuration)
    • showDefaultBackground

      public void showDefaultBackground(int animationDuration)
    • setBackgroundColor

      public void setBackgroundColor(Color color, int animationDuration)
    • exitFullScreen

      public void exitFullScreen()
    • addRootComponent

      public void addRootComponent(String containerElementSelector, Component component)
    • addRootPanel

      public void addRootPanel(String containerElementSelector, Component rootPanel)
    • addRootPanel

      public RootPanel addRootPanel(String containerElementSelector)
    • addRootPanel

      public RootPanel addRootPanel()
    • addClientToken

      public void addClientToken(String token)
    • removeClientToken

      public void removeClientToken(String token)
    • clearClientTokens

      public void clearClientTokens()
    • showNotification

      public void showNotification(Notification notification, NotificationPosition position, EntranceAnimation entranceAnimation, ExitAnimation exitAnimation)
    • showNotification

      public void showNotification(Notification notification, NotificationPosition position)
    • showNotification

      public void showNotification(Icon icon, String caption)
    • showNotification

      public void showNotification(Icon icon, String caption, String description)
    • showNotification

      public void showNotification(Icon icon, String caption, 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(String title, String message, String refreshButtonCaption, String cancelButtonCaption)
    • requestWakeLock

      public CompletableFuture<WakeLock> requestWakeLock()
    • goToUrl

      public void goToUrl(String url, boolean blankPage)
    • setFavicon

      public void setFavicon(Icon<?,?> icon)
    • setFavicon

      public void setFavicon(Resource resource)
    • setFavicon

      public void setFavicon(String url)
    • setTitle

      public void setTitle(String title)
    • setGlobalKeyEventsEnabled

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

      public String getSessionId()
    • handleStaticEvent

      public void handleStaticEvent(UiEvent event)
    • route

      public void route()
    • getAsUiSessionListenerInternal

      public UiSessionListener getAsUiSessionListenerInternal()
    • setName

      public void setName(String name)
    • getName

      public String getName()
    • getRoutingParamConverterProvider

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

      public UiSessionStats getUiSessionStats()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getRoutingMode

      public RoutingMode getRoutingMode()
    • setRoutingMode

      public void setRoutingMode(RoutingMode routingMode)
    • onDestroyed

      public Event<UiSessionClosingReason> onDestroyed()
      Same as onDestroyed but mockable.
    • subscribeToCustomMessages

      public Disposable subscribeToCustomMessages(String type, Consumer<CustomMessageEvent> handler)