Interface IUiSession

  • All Known Implementing Classes:
    UiSession

    @Bean
    public interface IUiSession
    • Field Detail

      • PREFERRED_LOCALE_COOKIE_NAME

        static final String PREFERRED_LOCALE_COOKIE_NAME
        Cookie name used to store the preferred language of a user (even after user has logged out).
        See Also:
        Constant Field Values
    • Method Detail

      • uiSessionLock

        ReentrantLock uiSessionLock()
        Returns a reentrant lock that can be used to synchronize on the IUiSession.
      • init

        void init​(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse resp,
                  JsonStartupRequest jsonStartupReq)
      • isPersistent

        boolean isPersistent()
        Used to mark the session as persistent which means a persistent session cookie is used and the client session will be restored after a browser restart.

        This was mainly introduced for the iOS home screen mode. If the app is running in that mode the HTTP session will be lost whenever the user leaves the app (e.g. switches to another app or just downloads a file). If persistent is set to true the client session id will be put in the local storage instead of the session storage so that it can be reused the next time the app is activated.

      • getHttpSessionId

        String getHttpSessionId()
      • getUiSessionId

        String getUiSessionId()
      • getClientSessionId

        String getClientSessionId()
      • touch

        void touch()
        All requests except the polling requests are calling this method from the JsonMessageRequestHandler

        Note that HttpSession.getLastAccessedTime() is also updated on polling requests

      • getLastAccessedTime

        long getLastAccessedTime()
        Returns:
        the last access time in millis since 01.01.1970 of a request, except polling requests

        see touch()

      • dispose

        void dispose()
        Marks the UI session is disposed (irreversible) and destroys the internal data structures and references (i.e. it disposes the JSON adapter registry).

        Important: This method must only be called in a context that holds the uiSessionLock()! (Either the current thread or a caller that waits for the current thread.)

      • isDisposed

        boolean isDisposed()
        Returns:
        true if dispose() has been called.
      • currentHttpRequest

        javax.servlet.http.HttpServletRequest currentHttpRequest()
      • currentHttpResponse

        javax.servlet.http.HttpServletResponse currentHttpResponse()
      • confirmResponseProcessed

        void confirmResponseProcessed​(Long sequenceNo)
        Used to confirm that the UI has successfully processed the given response sequence number. All responses that have a sequence number <= sequenceNo are removed from the response history.
      • verifySubject

        void verifySubject​(javax.servlet.http.HttpServletRequest request)
        Used to verify if the Subject we're running in should be replaced on the IClientSession.
        Parameters:
        request - the request that is checked if the update of the Subject has been requested
      • processJsonRequest

        JSONObject processJsonRequest​(javax.servlet.http.HttpServletRequest req,
                                      javax.servlet.http.HttpServletResponse resp,
                                      JsonRequest jsonReq)
        Returns:
        a JSON object to send back to the client or null if an empty response shall be sent.
      • processFileUpload

        JSONObject processFileUpload​(javax.servlet.http.HttpServletRequest req,
                                     javax.servlet.http.HttpServletResponse resp,
                                     IUploadable uploadable,
                                     List<org.eclipse.scout.rt.platform.resource.BinaryResource> uploadResources,
                                     Map<String,​String> uploadProperties)
        Parameters:
        req - the HTTP request
        uploadable - the target adapter that receives the uploaded files
        uploadResources - list of uploaded files
        uploadProperties - a map of all other submitted string properties (usually not needed)
        Returns:
        a JSON object to send back to the client or null if an empty response shall be sent.
      • processCancelRequest

        void processCancelRequest()
      • processSyncResponseQueueRequest

        JSONObject processSyncResponseQueueRequest​(JsonRequest jsonRequest)
      • logout

        void logout()
        Called from the model after the client session has been stopped.

        Important: Because this method internally calls dispose(), it must only be called in a context that holds the uiSessionLock()! (Either the current thread or a caller that waits for the current thread.)

      • getLogoutRedirectUrl

        String getLogoutRedirectUrl()
        Returns:
        the URL where to redirect the UI on logout
      • createUniqueId

        String createUniqueId()
      • getJsonAdapter

        IJsonAdapter<?> getJsonAdapter​(String id)
        Returns an existing IJsonAdapter instance for the given adapter ID.
      • getJsonAdapters

        <M> List<IJsonAdapter<M>> getJsonAdapters​(M model)
        Returns all JSON adapters which belong to the given model object.
      • getJsonAdapter

        <M,​A extends IJsonAdapter<M>> A getJsonAdapter​(M model,
                                                             IJsonAdapter<?> parent)
        Returns an existing IJsonAdapter instance for the given model object.
      • getJsonAdapter

        <M,​A extends IJsonAdapter<M>> A getJsonAdapter​(M model,
                                                             IJsonAdapter<?> parent,
                                                             boolean checkRoot)
      • getOrCreateJsonAdapter

        <M,​A extends IJsonAdapter<M>> A getOrCreateJsonAdapter​(M model,
                                                                     IJsonAdapter<?> parent)
        Creates a new initialized IJsonAdapter instance for the given model or returns an existing instance. As a side-effect a newly created adapter is added to the current JSON response.
      • registerJsonAdapter

        void registerJsonAdapter​(IJsonAdapter<?> adapter)
      • unregisterJsonAdapter

        void unregisterJsonAdapter​(IJsonAdapter<?> adapter)
      • waitForBackgroundJobs

        void waitForBackgroundJobs​(JsonRequest jsonRequest,
                                   int pollWaitSeconds)
                            throws InterruptedException
        Blocks the current thread/request until a model job started by a background job has terminated.
        Throws:
        InterruptedException
      • sendLocaleChangedEvent

        void sendLocaleChangedEvent​(Locale locale)
        Sends a "localeChanged" event to the UI. All locale-relevant data (number formats, texts map etc.) is sent along.
      • sendDisposeAdapterEvent

        void sendDisposeAdapterEvent​(IJsonAdapter<?> adapter)
        Sends an explicit "disposeAdapter" event to the UI. Usually, JSON adapters are disposed automatically when their parent adapter is disposed. However, for some adapters this has to be done manually, because their parent is not disposed (e.g. forms).
      • sendReloadPageEvent

        void sendReloadPageEvent()
        Sends a reload page event to trigger a page reload.
      • updateTheme

        void updateTheme​(String theme)
        Sets the new theme (session & cookie) and triggers a reload of the current page in the browser.