ICEpush JSP Integration Details

Table of Contents

ICEpush JSP Integration

ICEpush JSP integration includes 2 main elements:

  1. A set of JSP tags that can be included in the page to register pushIDs and manage regions of dynamic content.
  2. Server-side Notification infrastructure for injecting ICEpush context into a server-side bean.

JSP Tags

<icep:register>

The register tag creates a unique pushID and registers a JavaScript callback with it. It optionally declares a group that the pushID belongs to, and a notifier bean responsible for triggering notifications.

<icep:register callback="myScript" group="myGroup", notifier="myNotifier"/>
Attribute Required Description
callback A JavaScript callback function capable of handling notifications to the assigned pushID.
group A group name that the pushID will be registered with. If the group is not supplied it defaults to the pushID itself, resulting in a unique group of 1 for the pushID.
notifier A named bean that is responsible for triggering notifications to this pushID. The bean must be made available to the page through a <useBean> declaration, and must be in application or session scope.

<icep:region>

The region tag creates a unique pushID and associates it with a specific included page. The dynamic page content is included initially when the page loads, and is reloaded using an ajax GET when notifications occur to the pushID. The group name is included as a parameter to the GET request, so it is available to the included page. It optionally declares a <div> id for the updated region, a group that the pushID belongs to, and a notifier bean responsible for triggering notifications.

<icep:region id="myID" group="myGroup", notifier="myNotifier" page="/mypage.jsp"/>
Attribute Required Description
page The page containing the dynamic content. The path matches the syntax and usage of <jsp:include>
id ID of the <div> that will form the region and contain the dynamic content. If defined, it must be unique to the page. If not defined, it defaults to the unique pushID.
group A group name that the pushID will be registered with. If the group is not supplied it defaults to the pushID itself, resulting in a unique group of 1 for the pushID.
notifier A named bean that is responsible for triggering notifications to this pushID. The bean must be made available to the page through a <useBean> declaration, and must be in application or session scope.
evalJS Determines whether any embedded scripts in the content that is fetched after a Push notification are evaluated (default true). Evaluating embedded scripts does carry some client-side overhead that the developer should be aware of. If the region tag is fetching areas of large content that is known not to have any embedded scripts (eg. a large amount of table data), then performance may be improved by setting evalJS to false. Please note, that if it is required to nest region tags, the outer tags will have to have evalJS=true (default) for the rendered JavaScript of the inner region tags to be evaluated, which is required for the proper functioning of the region tag.

<icep:push>

The push tag causes a push notification to occur to the named group, on when the page loads.

<icep:push group="myGroup"/>
Attribute Required Description
group A group name to receive a push notification when this tag executes.

<icep:pushPeriodic>

The pushPeriodic tag causes a period push notification to occur to the named group, on a specified time interval. The precise behavior of the push timing is governed by the implementation of java.util.timer.

<icep:pushPeriodic group="myGroup" interval="5000" />
Attribute Required Description
group A group name to receive periodic push notifications.
interval Integer time in milliseconds of the interval between push notifications. A time <= 0 turns off the timer. The last interval set on a group prevails.

Inclusion of the pushPeriodic tag requires the following additional configuration in the web.xml.

<listener>
    <listener-class>
        org.icepush.integration.jsp.core.GroupIntervalTimer
    </listener-class>
</listener>

Notification

For notifications to occur, the notification business logic must have a valid PushContext to use. While in a normal or ajax-based request/response cycle the PushContext is readily available using the ServletContext.

PushContext pushContext = PushContext.getInstance(myServletContext);

If, however, notification triggers are to occur outside a request/response cycle, the notifying thread of execution still needs a valid PushContext to use. A common Notifier bean is provided that maintains a reference to the PushContext, and is initialized at page load time using the notifier attribute provided in the ICEpush JSP tag library.

Notifier

A Notifier is any POJO that extends the base class Notifier. The base class simply holds a reference to a valid PushContext, and provides the following API.

public void setPushContext(PushContext pc);
public PushContext getPushContext();
public void push(String group)

Group Notifier

GroupNotifier extends Notifier and simply maintains the group attribute associated with the tag. It provides the following additional API:

public void setGroup(String group);
public String getGroup();
public void push();

Group Naming

Group naming employees application-specific strategies. While group naming is orthogonal to JSP bean scopes, they can effectively be associated with a scope.

  • Window-scoped groups are not named, and use only the unique pushID assigned during registration. These names/pushIDs will change each time the page is loaded.
  • Session-scoped groups include the session ID: group="${session.id}.myGroup"
  • Application-scoped groups have static names: group="myGroup"
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2016 ICEsoft Technologies Canada Corp.