cancel
Showing results for 
Search instead for 
Did you mean: 

Portal Broadcasting

Former Member
0 Kudos

Back when we first upgraded to EP6 SP2, I remember reading something about a portal broadcasting tool (name may not be exact). Essentially, what it allows you to do is message everyone currently logged onto a portal instance. It was not something we actively pursued at the time, but now such a feature has been asked for.

Does anyone know what the name of this tool is? I can't seem to find it anywhere via search.

If the tool doesn't do what I want, any suggestions as to a custom app? I was thinking of an iview that would subscribe to an EPCM event and would pop up when the event was raised. It doesn't have to be fancy, just a way for us to say, alert all the current users of a dev environment that it will be going down in 10 minutes.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Shaohao,

Check out this blog from Prakash,

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I don't know anything about portal broadcast application. I tried Prakash code from his weblog and his application works but it has got 2 big problems. If user do not click in portal, the alert is not shown. And if message is valid for example for 3 minutes, every click to portal (during this 3 minutes) leads into new alert. So my opinion is that this solution is not real broadcasting.

I developed my own application (but take care, it's not so easy stuff :-). If you are interested I can give you some hints. But as I said this application could be 1 very big weblog...

With this application you can:

- display message immediately

- display message on every user login

- edit message text in XML forms builder

- selet time period in which is this message valid (from-to)

- display more messages in specified order

- select server node on which is message displayed (for example if you want restart only one server node)

- send message only to specified users (user/role/group)

Mabye you don't need all this funcionality. So try to ask specific question.

Ahoj

ONDREJ

Former Member
0 Kudos

hi ondrej,

I need some explanation on broadcasting messages to specific users. Could you send me the details to my mail.

jagdeep_2k@yahoo.com

thank you.

regs,

jaga

Former Member
0 Kudos

OK

here are some hints.

I'll write them here, so other users can also use them.

I think that its not possible to send messages to clients (we are on web) so clients have to ask repeatedly to server. Same mechanism works in real time collaboration. For this solution you should use Microsoft.XMLHTTP object. This object is hidden in page and can send request to specified server (goggle web for more info). Then you also need javascript timer object. If you control Microsoft.XMLHTTP with timer you can periodically send requests to server and user do not know anything about it. So you have to create Checker component ant put it somewhere on default framework page. Server sends respons in xml structure so this response is very small. In my implementation server sends url of XML file (created with XML forms builder) which should be displayed. If checker receives this responseand it contains lonk, it displays this file as broadcast message. Here is example of my checker component.

public class Checker extends AbstractPortalComponent {

	// nazvy parametru iView
	private final static String 			IVIEW_PAR_CHECKTIME = "z.checkTime";
		
	// default hodnoty parametru iView
	private final int						defaultCheckTime = 30;

	public void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
		LogWriter.traceInfo(LogWrapper.trace, LogWriter.traceEnter);
		
		String userID = request.getUser().getUniqueName();

		IPortalComponentProfile profile = request.getComponentContext().getProfile();
		
		int parCheckTime;
		try {
			parCheckTime = Integer.parseInt(profile.getProperty(IVIEW_PAR_CHECKTIME));	
		} catch (Exception e) {
			parCheckTime = defaultCheckTime;
		}
	
		StringBuffer sb = new StringBuffer();
		sb.append("<SCRIPT LANGUAGE="JavaScript">");
		sb.append("var timerID = null;");
		sb.append("var req;");
		sb.append("var first = true;");
		sb.append("function showtime(){");
		sb.append("timerID = setTimeout('showtime()',");
		sb.append(parCheckTime);
		sb.append("000);");
		sb.append("var currentTime = new Date();");
		sb.append("loadXMLDoc('/irj/servlet/prt/portal/prtroot/cz.sap.alert.Check?user=");
		sb.append(userID);
		sb.append("&first=' + first + ");
		sb.append("'&r=' + currentTime.getTime());");
		sb.append("first = false;");
		sb.append("}");
		sb.append("function loadXMLDoc(url) {");
		sb.append("req = false;");
		sb.append("if(window.XMLHttpRequest) {");
		sb.append("try {");
		sb.append("req = new XMLHttpRequest();");
		sb.append("} catch(e) {");
		sb.append("req = false;");
		sb.append("}");
		sb.append("} else if(window.ActiveXObject) {");
		sb.append("try {");
		sb.append("req = new ActiveXObject("Msxml2.XMLHTTP");");
		sb.append("} catch(e) {");
		sb.append("try {");
		sb.append("req = new ActiveXObject("Microsoft.XMLHTTP");");
		sb.append("} catch(e) {");
		sb.append("req = false;");
		sb.append("}");
		sb.append("}");
		sb.append("}");
		sb.append("if(req) {");
		sb.append("req.onreadystatechange = processReqChange;");
		sb.append("req.open("GET", url, true);");
		sb.append("req.send("");");
		sb.append("}");
		sb.append("}");
		sb.append("function processReqChange() {");
		sb.append("if (req.readyState == 4) {");
		sb.append("if (req.status == 200) {");
		sb.append("var alerts = req.responseXML.getElementsByTagName('alert');");
		sb.append("for (i=0;i<alerts.length;i++)");
		sb.append("{");
		sb.append("window.showModalDialog('");
		sb.append("/irj/go/km/docs");
		sb.append("' + ");
		sb.append("alerts<i>.firstChild.nodeValue");
		sb.append(",'','center:yes; status:no; resizable:no; dialogWidth:' + alerts<i>.getAttribute("width") + 'px;
dialogHeight:' + alerts<i>.getAttribute("height") + 'px;');");
		sb.append("}");
		sb.append("}");
		sb.append("}");
		sb.append("}");
		sb.append("showtime();");
		sb.append("</SCRIPT>");

		IPageContext pageContext = PageContextFactory.createPageContext(request, response);
		Document document = pageContext.createDocument("alerts");
		document.addRawText(sb.toString());
		document.render(pageContext);

		LogWriter.traceInfo(LogWrapper.trace, LogWriter.traceExit);		
	}
}

Then you have to create componet on server to which is checker iView asking. This component is returning XML response. Here is example of my component.

package cz.sap.alert;
 
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
import com.sapportals.portal.prt.runtime.PortalRuntime;

import cz.sap.logging.LogWriter;

/**
 * Servlet vracejici XLM soubor se seznamem upozorneni s jejich velikosti a adresou v KM
 * 
 * @author Ondrej Dedina
 */
public class Check extends AbstractPortalComponent
{
    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
    	
		// primy pristup do response
		HttpServletResponse resp = request.getServletResponse(true);
		
		// ziskani user id
		String userID = request.getParameter("user");
		
		// jde o prvni request
		String firstParameter = request.getParameter("first");
		boolean first;
		if (firstParameter.equals("true")) {
			first = true;
		} else {
			first = false;
		}
		
		try {
			
			// ziskani replication servisu
			IAlertReplicationService replicationService = (IAlertReplicationService) 
PortalRuntime.getRuntimeResources().getService(IAlertReplicationService.KEY);
			
			if (replicationService != null) {
				PrintWriter out = resp.getWriter();
				resp.setContentType("text/xml");
				out.print(replicationService.getXMLresult(userID, first));
				out.close();
			}

		} catch (IOException e) {
			LogWriter.traceError(LogWrapper.trace, e, LogWriter.extractCallStack(e), true);
		}

    }
}

Try to study it and try to stablish periodicall comunication between client and server. Than I can you give you more hints, if you need them.

Good Luck

Ahoj

ONDREJ

Former Member
0 Kudos

Thank you Onrej, for that detailed response. I've tried something similiar for another project but I never thought about using it in this context. I'm going to give it a try, but you've definently put me on the right path.

I'll post back here and update my progress later in the week.

Thanks again.

Former Member
0 Kudos

Shaohao,Onrej

I've created a project in NWDS with the two abstract portal components.

But NWDS can't resolve IAlertReplicationService etc..

I'm not a experienced java developer.

Can you help me?

Regards,

Andries Buter

Former Member
0 Kudos

Hi,

The problem is, that IAlertReplicationService is my service, not standart portal service. The code, which I puted to recent post was only hint and not How to guide :-). You definitely can not only cut and paste this code to NWDS... You don't need IAlertReplicationService service for portal broadcasting but you need cleary understand how my implementation of brodcasting is working...

Good luck

ONDREJ