Package de.xima.fc.gui.common.bean.push
Class ABackendPushContext
- java.lang.Object
-
- de.xima.fc.gui.common.bean.push.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 asViewPushChannelListener
). Then register your listener viaFormcycle.Push.*PushChannelListener.setInstance()
(such asFormcycle.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 Summary
Constructors Constructor Description ABackendPushContext()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract org.omnifaces.cdi.PushContext
getPushContext()
Set<Future<Void>>
sendAjaxCall(AjaxCallPushData ajaxConfig)
Performs an AJAX call with the given configuration.Set<Future<Void>>
sendEvent(ChannelMessage message)
Sends the given channel message to the client.Set<Future<Void>>
sendEvent(String eventName, Serializable payload)
Sends the given channel message to the client.Set<Future<Void>>
sendExecuteScript(String script)
Invokes the given JavaScript snippet on the client in the global scope.Set<Future<Void>>
sendFacesMessage(String summary, String detail, EFacesMessageSeverity severity, boolean saveInSession)
Displays the given faces message on the client.Set<Future<Void>>
sendFacesMessages(FacesMessagePushData... messages)
Displays the given faces messages on the client.Set<Future<Void>>
sendFacesMessages(String summary, String detail, EFacesMessageSeverity severity)
Displays the given faces message on the client.Set<Future<Void>>
sendFacesMessages(javax.faces.application.FacesMessage... messages)
Displays the given faces messages on the client.Set<Future<Void>>
sendRemoteCommand(String... remoteCommandName)
Invokes a remote command on the client.Set<Future<Void>>
sendRemoteCommand(String[] remoteCommandName, Map<String,Serializable> remoteCommandParams)
Invokes a remote command on the client with the given data.Set<Future<Void>>
sendUpdatePageTitle(String newTitle)
Changes the title of the page by modifying the text content of theTITLE
tag in theHEAD
.
-
-
-
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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
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 viaAPushChannelListener.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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
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 viaAPushChannelListener.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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
sendUpdatePageTitle
public Set<Future<Void>> sendUpdatePageTitle(String newTitle)
Changes the title of the page by modifying the text content of theTITLE
tag in theHEAD
.- 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
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
.
-
getPushContext
protected abstract org.omnifaces.cdi.PushContext getPushContext()
-
-