Hi,
in the past we used the portal service "epcftoolbox" to manage portal eventing between iViews. Now we are switching to WebDynpro development but we stil want having a communication to our former iViews.
Unfortunately the two variants have a different kind of data transfer. Epcftoolbox uses the client data bag but WDPortalEventing uses the direct way via a String-parameter called dataObject.
Is there someone who has succesfully combined the two features?
Best regards,
Marcus
Hi Marcus,
The following code works for me (sending event from WD iview to PDK iview):
In WD:
WDPortalEventing.fire("urn:com.company","theEvent",any_param);
In PDK (on Jsp page or on 'raw text' in a DynPage form):
EPCM.subscribeEvent( 'urn:com.company','theEvent',js_func_name); function js_func_name( eventObj ) { var x = eventObj.dataObject; alert(x); }
Of course, both iviews must be on the same page.
Omri
Hi Omri,
thanks for your answer. But you did not use the epcftoolbox which is a portal service. This service makes the necessary javaScript parts for you regarding clientside eventing. But it reads the data from client data bag instead from the dataObject.
Thats my problem. I wonder whether there is a possiblity to get the two kinds of eventing working together. I don't want to rewrite the existing iViews.
Best regards,
Marcus
PS: The JavaScript eventhandler created by the epcftoolbox service looks like this. You will see, that it don't uses the eventObject to read data from (except senderId).
function EpcfToolsReceiverHandler319(eventObject){ var myKey, myValue, mySepar, mySearchArrOld, mySearchArrNew, mySearch; var senderId = eventObject.sourceId; // Prepare Event data for sending to backend ... var eventData = escape("__EventUrn__")+"="+escape("TIMEACCOUNTPROOF_NAVIGATION")+"&"+escape("__EventName__")+"="+escape("buttonpressed"); var keys = EPCM.loadClientData("TIMEACCOUNTPROOF_NAVIGATION","AllKeys"); var keyArr = keys.split("&"); for(var i=0; i<keyArr.length; i++){ myKey = keyArr<i>; myValue = EPCM.loadClientData("TIMEACCOUNTPROOF_NAVIGATION",keyArr<i>); mySepar = (eventData.length>0) ? "&" : ""; eventData += mySepar+escape(myKey)+"="+escape(myValue); } // for // Prepare final query string... mySearchArrNew = new Array(); mySearchArrNew[0] = escape("EventData")+"="+escape(eventData); if(location.search.length > 0){ mySearchArrOld = location.search.substring(1).split("&"); for(var i=0; i<mySearchArrOld.length; i++){ if(mySearchArrOld<i>.indexOf("EventData=")==0) continue; mySearchArrNew[mySearchArrNew.length] = mySearchArrOld<i>; } } mySearch = "?" + mySearchArrNew.join("&"); var myBodyTag = document.getElementsByTagName("BODY"); myBodyTag[0].innerHTML = "<TABLE><TR><TD>Bitte warten, die Daten werden gerade geladen ...</TD></TR></TABLE>"; location.search = mySearch; } // function EPCM.subscribeEvent("TIMEACCOUNTPROOF_NAVIGATION","buttonpressed",EpcfToolsReceiverHandler319);
I was not able to leave the already existing iViews without a change. I would like to tell my solution.
My scenario is as follows:
- the event sender is a WebDynpro iView
- the event receiver is a native java iView; it uses the portal service EpcfToolBox
With the EpcfToolBox it was able to transfer <b>multiple</b> parameters with the event. With the Web Dynpro portal eventing it is only able to transfer <b>one</b> parameter. Because of that I decided to transfer the data of the WebDynpro iView within one string of the form: <i>parameter 1=value 1&...parameter n = value n</i>.
The following is the code from the Web Dynpro iView, which fires an event:
StringBuffer parameterBuffer = new StringBuffer(); parameterBuffer.append("selection=20070109"); parameterBuffer.append("&"); parameterBuffer.append("viewmodus=0"); parameterBuffer.append("&"); parameterBuffer.append("pernr=123456"); WDPortalEventing.fire("urn:com.zf.overtime","timeproofselection",parameterBuffer.toString());
The next parts describe the actions on the native java iView side.
The EpcfToolBox portal service is not able to retrieve the data, which above is written into the parameterBuffer. So I unfortunately needed to modify the already existing iView.
1. implement a new IClientEventReceiver (with new urn):
IClientEventReceiver myReceiverWDPortal = myServ.getClientEventReceiver( request "urn:com.zf.overtime", "timeproofselection"); myReceiverWDPortal.setEventFilter(IClientEventReceiver.EVENT_FILTER_ALL);
2. Instead of using myReceiverWDPortal.getWrappedScript(), write the following JavaScript into the response object.
String wr = "nt"; StringBuffer buffer = new StringBuffer(); buffer.append("<SCRIPT language="JavaScript">"+wr); buffer.append("function WDPortalEventReceiverHandler(eventObject){"+wr); buffer.append("var myKey, myValue, mySepar, mySearchArrOld, mySearchArrNew, mySearch;"+wr); buffer.append("var senderId = eventObject.sourceId;"+wr); buffer.append("var eventData = escape("__EventUrn__")+"="+escape("urn:com.zf.overtime")+"&"+escape("__EventName__")+"="+escape("timeproofselection");"+wr); buffer.append("var keys = eventObject.dataObject;"+wr); buffer.append("var keyArr = keys.split("&");"+wr); buffer.append("for(var i=0; i<keyArr.length; i++){"+wr); buffer.append(" myKey = keyArr<i>;"+wr); buffer.append(" mySepar = (eventData.length>0) ? "&" : "";"+wr); buffer.append(" eventData += mySepar+myKey;"+wr); buffer.append("}"+wr); buffer.append("mySearchArrNew = new Array();"+wr); buffer.append("mySearchArrNew[0] = escape("EventData")+"="+escape(eventData);"+wr); buffer.append("if(location.search.length > 0){"+wr); buffer.append(" mySearchArrOld = location.search.substring(1).split("&");"+wr); buffer.append(" for(var i=0; i<mySearchArrOld.length; i++){"+wr); buffer.append(" if(mySearchArrOld<i>.indexOf("EventData=")==0) continue;"+wr); buffer.append(" mySearchArrNew[mySearchArrNew.length] = mySearchArrOld<i>;"+wr); buffer.append(" }"+wr); buffer.append("}"+wr); buffer.append("mySearch = "?" + mySearchArrNew.join("&");"+wr); buffer.append(" var myBodyTag = document.getElementsByTagName("BODY");"+wr); buffer.append(" myBodyTag[0].innerHTML = "<TABLE><TR><TD>Bitte warten, die Daten werden gerade geladen ...</TD></TR></TABLE>";"+wr); buffer.append(" location.search = mySearch;"+wr); buffer.append("}"+wr); buffer.append("EPCM.subscribeEvent("urn:com.zf.overtime","timeproofselection",WDPortalEventReceiverHandler);"+wr); buffer.append("</SCRIPT>"+wr); response.write(buffer.toString());
You have to change the urn and eventname to the desired values.
3. implement the event receiving case:
if (myReceiver.isReceived() || myReceiverWDPortal.isReceived()) { if (myReceiverWDPortal.isReceived()){ myReceiver = myReceiverWDPortal; } timeaccountBean.setSelectedMonth(myReceiver.getParameter("selection")); timeaccountBean.setViewModus(myReceiver.getParameter("viewmodus")); timeaccountBean.setPerNr(myReceiver.getParameter("perNr");
In this case myReceiver is the original implemented EventReceiver. So this part works now for events which are fired by EpcfToolBox and which are fired by WDPortalEventing.
Hope this helps.
Best regards,
Marcus
Message was edited by:
Marcus Freiheit
Add a comment