Top Description Fields Constructors Methods
com.sun.faces.push

public Class WebsocketFacesListener

extends Object
implements SystemEventListener
Class Inheritance
All Implemented Interfaces
javax.faces.event.SystemEventListener, javax.faces.event.FacesListener, java.util.EventListener
Imports
java.util.HashMap, .List, .Map, .Map.Entry, javax.faces.component.UIOutput, .UIViewRoot, .UIWebsocket, javax.faces.context.FacesContext, .PartialViewContext, javax.faces.event.AbortProcessingException, .ComponentSystemEvent, .PostAddToViewEvent, .PreRenderViewEvent, .SystemEvent, .SystemEventListener, javax.faces.push.Push

This JSF listener for UIViewRoot ensures that the necessary JavaScript code to open or close the WebSocket is properly rendered depending on rendered and connected attributes.

Author
Bauke Scholtz
Since
2.3
See Also
Push

Field Summary

Modifier and TypeField and Description
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static Map<String, Boolean>
public boolean
isListenerForSource(Object
the source that is inquiring about the appropriateness of sending an event to this listener instance.
source
)

Implements javax.faces.event.SystemEventListener.isListenerForSource.

Only listens on UIViewRoot.
public static boolean
isNew(FacesContext context, UIWebsocket websocket)

public void
processEvent(SystemEvent
the SystemEvent instance that is being processed.
event
)

Implements javax.faces.event.SystemEventListener.processEvent.

If the websocket has just switched its rendered or connected attribute, then render either the open() script or the close() script.
public static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

SCRIPT_CLOSEback to summary
private static final String SCRIPT_CLOSE
SCRIPT_OPENback to summary
private static final String SCRIPT_OPEN

Constructor Detail

WebsocketFacesListenerback to summary
public WebsocketFacesListener()

Method Detail

getInitializedWebsocketsback to summary
private static Map<String, Boolean> getInitializedWebsockets(FacesContext context)
Annotations
@SuppressWarnings:unchecked
isListenerForSourceback to summary
public boolean isListenerForSource(Object source)

Implements javax.faces.event.SystemEventListener.isListenerForSource.

Only listens on UIViewRoot.

Parameters
source:Object

Doc from javax.faces.event.SystemEventListener.isListenerForSource.

the source that is inquiring about the appropriateness of sending an event to this listener instance.

Returns:boolean

Doc from javax.faces.event.SystemEventListener.isListenerForSource.

the value as specified above

Annotations
@Override
isNewback to summary
public static boolean isNew(FacesContext context, UIWebsocket websocket)
processEventback to summary
public void processEvent(SystemEvent event) throws AbortProcessingException

Implements javax.faces.event.SystemEventListener.processEvent.

If the websocket has just switched its rendered or connected attribute, then render either the open() script or the close() script. During an ajax request with partial rendering, it's added as <eval> by partial response writer, else it's just added as a script component with target="body".

Parameters
event:SystemEvent

Doc from javax.faces.event.SystemEventListener.processEvent.

the SystemEvent instance that is being processed.

Annotations
@Override
Exceptions
AbortProcessingException:

Doc from javax.faces.event.SystemEventListener.processEvent.

if lifecycle processing should cease for this request.

subscribeIfNecessaryback to summary
public static void subscribeIfNecessary(FacesContext context)