Skip to Content
Author's profile photo Former Member

An Effortless Chatting IView

This Weblog explains a simple application to develop a Chatting iview.

Difficulty in sharing a variable:

When two users of the portal open the same iview, separate instances of the portal component are created for each of them. So any variable created within that component will be local to that instance and can not be accessed by the other instance. Even the Bean variables stored in IPortalComponentProfile can not be shared between different instances as the profile is also relative to each instance.

Generally, sharing of data among iviews is done at the client side through EPCF’s DataBags or at server side using Portal Services. Both these techniques requires adding some extra code fragments to the main business logic.

But, this application neither uses EPCF nor Portal services to share a variable between two instances of the same iview. This concept is very simple and can also be used to share data between two different iviews.

Description of the Portal Component :

This application uses single JspDynPage that calls a jsp page. The jsp page consists of a Input Field, Listbox and some buttons. These buttons are associated with their corresponding eventing methods in the JspDynPage.

Code Sample

This portal component is deployed in the server and made as a single iview. Now URL of that iview can be sent to all the portal users of that server and this chatting application is available on the server.

Sharing the bean variable:

This application uses a Bean with application scope (session scope also works), which consists of a static member which acts as a global variable to all instance of that iview. Unless the project is deployed again, value stored in such a static variable will not be cleared or re-initialised.

In this application, the static member is an IListModel in which chatting conversation by different users gets stored. Non-static IListModel or a local model is used to display the contents at the Listbox. This local model gets only the currently available conversation and displays in the Listbox. The eventing algorithms of the buttons are given below.

Initial and Refreshing event:

Items of a global model from a reference are copied to the local model

Sending event:

Stores the text from the input field to the static IListModel of the bean.

Clearing event:

Makes the local model empty and changes the reference to the end of the global model.

On opening the iview, it displays an empty Listbox, to which conversation can be added as each item.


On clicking the refresh button, the recent conversations by other users online will be seen in the Listbox. On clicking the clear button, current items of the Listbox will be cleared. This will not affect the chatting page of other users, since each page uses a local model to populate its Listbox.

As a conclusion, I would mention that, just defining a bean member as STATIC makes it sharable among different instances of that iview. Beginners can make use of this concept to achieve iview communication easily.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.