Class ABackendPushContext

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    BackendApplicationPushContext, BackendSessionPushContext, BackendViewPushContext

    public abstract class ABackendPushContext
    extends Object
    implements Serializable
    Base class for backend push contexts (web sockets) with some utility methods for commonly used message, such as requesting an AJAX update or invoking a remote command.

    On the client side, you should create an appropriate sub class of one of the available APushChannelListener (such as ViewPushChannelListener). Then register your listener via Formcycle.Push.*PushChannelListener.setInstance() (such as Formcycle.Push.ViewPushChannelListener.setInstance()). This instance is automatically registered as a listener for the OmniFaces push web socket.

    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    See Also:
    Serialized Form
    • Constructor Detail

      • ABackendPushContext

        public ABackendPushContext()
    • Method Detail

      • sendAjaxCall

        public Set<Future<Void>> sendAjaxCall​(AjaxCallPushData ajaxConfig)
        Performs an AJAX call with the given configuration. When no form ID or source is specified, uses a default form and source.
        Parameters:
        ajaxConfig - Configuration for the AJAX call.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendEvent

        public Set<Future<Void>> sendEvent​(ChannelMessage message)
        Sends the given channel message to the client. Make sure you also subscribe to this event in your client-side push channel listener implementation via APushChannelListener.prototype.on.
        Parameters:
        message - Message to send.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendEvent

        public Set<Future<Void>> sendEvent​(String eventName,
                                           Serializable payload)
        Sends the given channel message to the client. Make sure you also subscribe to this event in your client-side push channel listener implementation via APushChannelListener.prototype.on.
        Parameters:
        eventName - Name of the event to send to the client.
        payload - Payload data to send for the event.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendExecuteScript

        public Set<Future<Void>> sendExecuteScript​(String script)
        Invokes the given JavaScript snippet on the client in the global scope.
        Parameters:
        script - JavaScript snippet to execute on the client.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendFacesMessage

        public Set<Future<Void>> sendFacesMessage​(String summary,
                                                  String detail,
                                                  EFacesMessageSeverity severity,
                                                  boolean saveInSession)
        Displays the given faces message on the client.
        Parameters:
        summary - Summary of the message.
        detail - Detail of the message.
        severity - Severity of the message.
        saveInSession - Whether the message should be saved in the session.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendFacesMessages

        public Set<Future<Void>> sendFacesMessages​(javax.faces.application.FacesMessage... messages)
        Displays the given faces messages on the client.
        Parameters:
        messages - Faces messages to display.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendFacesMessages

        public Set<Future<Void>> sendFacesMessages​(FacesMessagePushData... messages)
        Displays the given faces messages on the client.
        Parameters:
        messages - Faces messages to display.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendFacesMessages

        public Set<Future<Void>> sendFacesMessages​(String summary,
                                                   String detail,
                                                   EFacesMessageSeverity severity)
        Displays the given faces message on the client.
        Parameters:
        summary - Summary of the message.
        detail - Detail of the message.
        severity - Severity of the message.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendRemoteCommand

        public Set<Future<Void>> sendRemoteCommand​(String... remoteCommandName)
        Invokes a remote command on the client.
        Parameters:
        remoteCommandName - Name of the remote command to invoke. Lookup starts in the global window scope.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendRemoteCommand

        public Set<Future<Void>> sendRemoteCommand​(String[] remoteCommandName,
                                                   Map<String,​Serializable> remoteCommandParams)
        Invokes a remote command on the client with the given data.
        Parameters:
        remoteCommandName - Name of the remote command to invoke. Lookup starts in the global window scope.
        remoteCommandParams - Optional key value pairs to pass through to the remote command.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • sendUpdatePageTitle

        public Set<Future<Void>> sendUpdatePageTitle​(String newTitle)
        Changes the title of the page by modifying the text content of the TITLE tag in the HEAD.
        Parameters:
        newTitle - The new page title.
        Returns:
        The results of the send operation. If it returns an empty set, then there was no open web socket session associated with given socket channel. The returned futures will return null on Future.get() if the message was successfully delivered and otherwise throw ExecutionException.
      • getPushContext

        protected abstract org.omnifaces.cdi.PushContext getPushContext()