cancel
Showing results for 
Search instead for 
Did you mean: 

EPCF - from Javascript to JSP

Former Member
0 Kudos

Hi y'all,

I’m trying to develop a reporting portal app, which will comprises 2 iViews. The first iView (V1) displays a table listing data retrieved from a bapi. Depending on which row is selected from this table, the second iView (V2) displays its own table listing the corresponding item specific information retrieved from a second bapi.

I am still in the process of prototyping the system and have taken an epcf approach to allow simplex communication between iViews. (and I’ve hard-coded the table model in V1 for prototyping purposes).

Now that I’ve been successful in transferring data from V1 to V2, I think I may have overlooked a fundamental issue in taking an epcf approach in that ecpf uses javascript which is run on client-side. Does this mean that it would be impossible to use data sent from V1 to invoke a bapi from within V2's context? i.e. pass data from javascript to the components code.

Any suggestions???

Accepted Solutions (1)

Accepted Solutions (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Sergio,

no, that's no problem at all. The way it works is that you'll use EPCF eventing API so that you register V2 for (update) events sent by V1 including a parameter (from row selection, we already had this ). Within V2, a JS method is called upon V1-selection-events, which will update itself with the new value, so a server-roundtrip will occur. Everything you want.

For sure it would make sense to have some caching implemented, but also this you should do on server side for simplicity reasons.

Hope it helps

Detlev

Former Member
0 Kudos

Detlev,

I'm not sure whether I completely understood what your what approach. What i ended up doing was (which is probably not the best solution):

~~~~~~~~~~~~~~~V1~~~~~~~~~~~

V1's.jsp:

...

<%myTableView.setOnClientRowSelection("raiseEvent()");%>

...

function reiseEvent(){

EPCM.storeClientData(<urn>, <data_id>, <data>);

EPCM.raiseEvent(<urn>, <event_name>, <data>, <id>);

}

~~~~~~~~~~~~~~~V2~~~~~~~~~~~

V2's.jsp:

...

function foundEvent(){

location.search = 'employee='+EPCM.loadClientData(<urn>, <data_id>);

}

EPCM.subscribeEvent(<urn>, <event_name>, foundEvent);

...

V2's.java:

.....

if(request.getParameter("employee")!= null)

bean.setEmployeeID(request.getParameter("employee"));

.....

though I would however prefer not to pass parameters in the url.

detlev_beutner
Active Contributor
0 Kudos

Hi Sergio,

this is more or less what I'm thinking of.

Some remarks:

You don't need the ClientDataBag in this case. Just pass the data you want to pass by the raiseEvent method as the third parameter (the fourth you don't need).

The foundEvent method is called with an eventObj parameter. From this you can get the data. Please reread https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/enterpris... portal client.pdf around page 10.

Use URL isolation mode.

You could - with some amount of work - have a hidden input field within iView 2, set the value from JS method and fire the event for some send button; but this will be really ugly JS (at least I think that only non-existing JS is good JS) and I don't see real problems using URL paramaters?!

Hope it helps

Detlev

Answers (0)