Class PendingJavaScriptInvocation

    • Constructor Detail

      • PendingJavaScriptInvocation

        public PendingJavaScriptInvocation​(StateNode owner,
                                           UIInternals.JavaScriptInvocation invocation)
        Creates a new pending invocation for the given owner node and invocation.
        Parameters:
        owner - the state node that this invocation is related to, not null
        invocation - the JavaScript invocation to send, not null
    • Method Detail

      • getOwner

        public StateNode getOwner()
        Gets the state node that this invocation belongs to.
        Returns:
        the owner state node
      • isSubscribed

        public boolean isSubscribed()
        Checks if there are any subscribers for the return value of this expression.
        Returns:
        true if the return value should be passed back from the client, false if the return value can be ignored
      • complete

        public void complete​(elemental.json.JsonValue value)
        Completes this invocation with the given return value from the client. Should only be used if there return value subscribers.
        Parameters:
        value - the JSON return value from the client
      • completeExceptionally

        public void completeExceptionally​(elemental.json.JsonValue value)
        Completes this invocation with the given exception value from the client. Should only be used if there return value subscribers.
        Parameters:
        value - the JSON exception value from the client
      • isSentToBrowser

        public boolean isSentToBrowser()
        Description copied from interface: PendingJavaScriptResult
        Checks whether the JavaScript execution has already been sent to the browser. It is no longer possible to cancel the execution or add a handler for the result after the execution has been sent.
        Specified by:
        isSentToBrowser in interface PendingJavaScriptResult
        Returns:
        true if the execution is sent to the browser, false if it's still pending
      • then

        public void then​(SerializableConsumer<elemental.json.JsonValue> successHandler,
                         SerializableConsumer<String> errorHandler)
        Description copied from interface: PendingJavaScriptResult
        Adds an untyped handler that will be run for a successful execution and a handler that will be run for a failed execution. One of the handlers will be invoked asynchronously when the result of the execution is sent back to the server. It is not possible to synchronously wait for the result of the execution while holding the session lock since the request handling thread that makes the result available will also need to lock the session.

        Handlers can only be added before the execution has been sent to the browser.

        Specified by:
        then in interface PendingJavaScriptResult
        Parameters:
        successHandler - a handler for the JSON representation of the value from a successful execution, not null
        errorHandler - a handler for an error message in case the execution failed, or null to ignore errors
      • isCanceled

        public boolean isCanceled()
        Checks whether this invocation has been canceled.
        Returns:
        true if the invocation has been canceled, otherwise false
      • getInvocation

        public UIInternals.JavaScriptInvocation getInvocation()
        Gets the underlying JavaScript invocation that this pending invocation is based on.
        Returns:
        the JavaScript invocation, not null