Class AbstractConlet<S>

Type Parameters:
S - the type of the conlet’s state information
All Implemented Interfaces:
Iterable<ComponentType>, Channel, ComponentType, Eligible, Manager
Direct Known Subclasses:

public abstract class AbstractConlet<S> extends Component
Provides a base class for implementing web console components.

The class provides the following support functions:

  • “Translate” the conlet related events to invocations of abstract methods. This is mainly a prerequisite for implementing the other support functions.
  • Optionally manage state for a conlet instance.
  • Optionally track the existing previews or views of a conlet, thus allowing the server side to send update events (usually when the state changes on the server side).
  • Optionally refresh existing previews or views periodically

Event handling

The following diagrams show the events exchanged between the WebConsole and a web console component from the web console component’s perspective. If applicable, they also show how the events are translated by the AbstractConlet to invocations of the abstract methods that have to be implemented by the derived class (the web console component that provides a specific web console component type).


Add web console component type handling

From the web console’s page point of view, a web console component consists of CSS and JavaScript that is added to the console page by AddConletType events and HTML that is provided by RenderConlet events (see below). These events must therefore be generated by a web console component.

The AbstractConlet does not provide support for generating an AddConletType event. The handler for the ConsoleReady that generates this event must be implemented by the derived class itself.


Add web console component handling

The AddConletRequest indicates that a new web console component instance of a given type should be added to the page. The AbstractConlet checks the type requested, and if it matches, invokes generateInstanceId and createNewState. If the conlet has associated state, the information is saved with putInSession. Then doRenderConlet is invoked, which must render the conlet in the browser. Information about the rendered views is returned and used to track the views.

Method doRenderConlet renders the preview or view by firing a RenderConlet event that provides to the console page the HTML that represents the web console component on the page. The HTML may be generated using and thus depending on the component state. Alternatively, state independent HTML may be provided followed by a NotifyConletView event that updates the HTML (using JavaScript) on the console page. The latter approach is preferred if the model changes frequently and updating the rendered representation is more efficient than providing a new one.


Render web console component handling

A RenderConletRequest event indicates that the web console page needs the HTML for displaying a web console component. This may be caused by e.g. the initial display, by a refresh or by requesting a full page view from the preview.

Upon receiving such an event, the AbstractConlet checks if it has state information for the component id requested. If not, it calls recreateState which allows the conlet to e.g. retrieve state information from a backing store.

Once state information has been obtained, the method continues as when adding a new conlet by invoking doRenderConlet.


Web console component deleted handling

When the AbstractConlet receives a ConletDeleted event, it updates the information about the shown conlet views. If the conlet is no longer used in the browser (no views remain), it deletes the state information from the session. In any case, it invokes doConletDeleted with the state information.


Notify web console component model handling

If the web console component views include input elements, actions on these elements may result in NotifyConletModel events from the web console page to the web console. When the AbstractConlet receives such events, it retrieves any existing state information. It then invokes doUpdateConletState with the retrieved information. The web console component usually responds with a NotifyConletView event. However, it can also re-render the complete conlet view.

Support for unsolicited updates

The class tracks the relationship between the known ConsoleConnections and the web console components displayed in the console pages. The information is available from conletInfosByConsoleConnection. It can e.g. be used to send events to the web console(s) in response to an event on the server side.