In the same project (com.ust.broadcast) build a JSPDynPage component that gets alert and displays it as a popup by calling a dynpage component(defined in step4). Use the JSPDynPage wizard to create component called

display

. The code should look like following(cut and paste).

Display.Java

/* Built By: Prakash Singh

Technical Consultant

Universal System Technologies, Inc

2500 W. Lake Mary Blvd., Ste 212-A

Lake Mary, FL 32746 USA

M 407-474-2216

*/

package com.ust.broadcast;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.JSPDynPage;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.prt.component.IPortalComponentContext;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentURI;

import com.sapportals.portal.prt.runtime.PortalRuntime;

import com.ust.broadcast.bean.alertinfo;

//import bean.ContextBean;

public class display extends PageProcessorComponent {

public DynPage getPage() {

return new displayDynPage();

}

public static class displayDynPage extends JSPDynPage {

private alertinfo bean;

private final static String BEAN_KEY = “myBean”;

public void doInitialization() {

bean = null;

IPortalComponentRequest request =

(IPortalComponentRequest) this.getRequest();

IPortalComponentContext context = request.getComponentContext();

IPortalComponentURI uri = request.createPortalComponentURI();

uri.setContextName(“com.ust.broadcast.popup”);

Ialertreceiver receiver =

(Ialertreceiver) PortalRuntime

.getRuntimeResources()

.getService(

Ialertreceiver.KEY);

if (!receiver.GetMessage().equals(“”)) {

receiver.GetMessage();

}

Object o = context.getValue(BEAN_KEY);

if (o instanceof alertinfo) {

bean = (alertinfo) o;

}

if (bean == null) {

// no bean or probably wrong class.

// We simply instantiate a new bean and put

// it into the session

bean = new alertinfo();

}

bean.url = uri.toString();

if (!receiver.GetMessage().equals(“”))

bean.no_message = “false”;

else

bean.no_message = “true”;

context.putValue(BEAN_KEY, bean);

}

public void doProcessAfterInput() throws PageException {

}

public void doProcessBeforeOutput() throws PageException {

this.setJspName(“displayalert.jsp”);

}

}

}

/* Built By: Prakash Singh

Technical Consultant

Universal System Technologies, Inc

2500 W. Lake Mary Blvd., Ste 212-A

Lake Mary, FL 32746 USA

M 407-474-2216

*/

package com.ust.broadcast.bean;

public class alertinfo

{

public String url;

public String no_message;

public String geturl() {

return url;

}

public String no_message() {

return no_message;

}

}

Step 4

In the same project (com.ust.broadcast) build a DynPage component called

popupup

that displays the message

Source code for popup.java. (Cut and Paste)

/* Built By: Prakash Singh

Technical Consultant

Universal System Technologies, Inc

2500 W. Lake Mary Blvd., Ste 212-A

Lake Mary, FL 32746 USA

M 407-474-2216

*/

package com.ust.broadcast;

import com.sapportals.htmlb.Form;

import com.sapportals.htmlb.GridLayout;

import com.sapportals.htmlb.Group;

import com.sapportals.htmlb.Label;

import com.sapportals.htmlb.TextEdit;

import com.sapportals.htmlb.TextView;

import com.sapportals.htmlb.enum.GroupDesign;

import com.sapportals.htmlb.enum.TextViewDesign;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.prt.runtime.PortalRuntime;

public class popup extends PageProcessorComponent {

public DynPage getPage() {

return new popupDynPage();

}

public static class popupDynPage extends DynPage {

/**

Initialization code executed once per user.

*/

public void doInitialization() {

}

/**

Input handling code. In general called the first time with the second page request from the user.

*/

public void doProcessAfterInput() throws PageException {

}

/**

Create output. Called once per request.

*/

public void doProcessBeforeOutput() throws PageException {

Form myForm = this.getForm(); // get the form from DynPage

Ialertreceiver receiver =

(Ialertreceiver) PortalRuntime

.getRuntimeResources()

.getService(

Ialertreceiver.KEY);

Group myGroup = new Group();

myGroup.setTitle(“System Message”);

myGroup.setWidth(“450”);

myGroup.setDesign(GroupDesign.SAPCOLOR);

GridLayout gl = new GridLayout();

myGroup.addComponent(gl);

Label lblauthor = new Label(“Author”);

gl.addComponent(1,1,lblauthor);

TextView author = new TextView(“Author”);

author.setText(receiver.GetUserid());

author.setDesign(TextViewDesign.HEADER2);

gl.addComponent(2,1,author);

Label lblmessage = new Label(“Message”);

gl.addComponent(3,1,lblmessage);

TextEdit alert = new TextEdit(“message”);

alert.setCols(80);

alert.setRows(6);

alert.setText(receiver.GetMessage());

gl.addComponent(4,1,alert);

myForm.addComponent(myGroup);

// create your GUI here….

}

}

}

The setup of this component in portal is explained in the part2 of this weblog

Dear Prakash,you had published wonderful blog on Broad casting messages almost 5 years ago.till now I haven’t seen any updated blog on SDN,it shows your unique talent. I got a req to send messages to portal users about system updates.

I tried to implement your code and was able to deploy your code but not able to get display iview working.even popup is receiving the data from Publish view but some how the comunication between Display and popup is mising.was it probelm with Portal 7.0?.Could you please send me Jar file or any hint for fixing this.

Hi Rem, Thank you so much. My current solution is not truely realtime because it captures broadcasted messages only when the user navigates between pages. You can add a server side timer component(that looks for message after some interval) to make it real time. You can extend this to do chat as well but SAP already provides very good chat tool via Collaboration.Prakash Singh

Hi, great work prakash.I’m trying to use it, but all ‘import’swith ‘notification’ (com.sapportals.portal.prt.service.notification…) can’t be solved.I’m using Portal from NW04 SP10, any idea, where I can get these ?

Hi Michael, Thank you for the feedback. The class is inside prtcoreservice.jar . Search under your portal install directory. If you don’t find it then email me at psingh@ust.net. I will send it to you.

Hi Prakash,thanks for your reply, I could find the class and deploy the project. I created the IViews and modified the Desktop Framework as described. But if I want to run the ‘publish’ IView, I get an error message. In the Log File I can see messages ‘error in init method’ and ‘java.lang.ClassNotFoundException’. Do you have any idea ?RegardsMichael Scholz

Hi,iam trying to make the application but but all ‘import’swith ‘notification’ (com.sapportals.portal.prt.service.notification…) can’t be solved.Iv got the jar ptcoreservice,but do not know how to get classes.

Hi Prakash,I have been looking into Portal messenging and have come across your Blog. It is excellent work. I am not a programmer, sorry, so I am wondering can you send me the par file for your portal broadcast messages that will work on NW2004s? RegardsBrian Lane

Hi PrakashThat was wonderfully framed.But if we put the Display iView in Desktop Innerpage, everytime user clicks on any workset the popup appears. If I want the popup just after login only, what should be done.

This is Excelent weblog.When i’m trying to use this,I got error when deploying popup component.we’re using EP 7.0.Is there any changes for the ep 7.0.If posible send par file to mymail kumar.portal@k.stThanks,Kumar

I loved to read about the possibility of sending messages to all logged on users, but currently I’m not able to follow the steps describes in this blog. We’re using NWDS 7.0.17, an I’m not sure what you mean with a “portal service”. I cannot find such a project or DC type in my NWDS, as well as I do not know what you mean with a DynPage or a JSPDynPage. Can you help me in translating that into my somewhat wellknown world of NWDS 7.0 ?