cancel
Showing results for 
Search instead for 
Did you mean: 

ecpm subscribe event not working

andjelka_radjen
Participant
0 Kudos

I am a currently working on converting my programming code from EP5 to EP6. I have not changed anything in my JSP page/javascript but for some reason my eventing is not working now.

I have 4 iviews on a page which talk to each other. I a testing them in preview mode. Based on inputting data in the first iview data is sent via EPCM to the second iview and the second iview subscribes to the event from the first iview and it works fine. However, when the second iview raises an event which is supposed to be picked up by the 3rd iview nothing happens. I believe the raise event is working in the 2nd iview as I have an alert in there and it does alert. I think the problem is that the function in the 3rd iview is never executed ...

Here are code snippets from the two jsp files that should be communicating. Any help would be greatly appreciated.

<b>JSP Code snippet from the 2nd iview to raise the event:</b>

<% // Add script to catch the event when the detail button is clicked

if(componentRequest.getValue("refreshOrderDetail")!=null){

%>

<script language="JavaScript">

// Set the variable for the order number and material

var order_material = "<%= MyJCoBean.getCurOrder() %>".concat("_").concat("<%= MyJCoBean.getMaterial() %>").concat("_").concat("<%= MyJCoBean.getActivity() %>");

EPCM.storeClientData ( 'urn:myOwnNameSpace', 'processOrderDetail', order_material);

EPCM.raiseEvent( 'urn:myOwnNameSpace', 'processOrderDetail', order_material);

alert(order_material);

</script>

<%

} // end of if block

%>

<b>Here is the code from the 3rd iview which has a function in it which is never executed because the

alert inside the function never gets executed:</b>

<script language="JavaScript">

EPCM.subscribeEvent( 'urn:myOwnNameSpace', 'processOrderDetail', <%=jsFunctionName%> );

function <%=jsFunctionName%> ( evt ) {

var eventData = evt.dataObject;

alert("I am in the funtion");

var sel_order = eventData.substring(0,eventData.indexOf("_"));

var start_pos = eventData.indexOf("_",0) + 1;

var sel_material = eventData.substring(start_pos,eventData.indexOf("_",start_pos));

var day_pos = eventData.indexOf("_",start_pos) + 1;

var end_pos = eventData.length;

var day_activity = eventData.substring(day_pos,end_pos);

alert("i am in orderdetail.jsp");

document.forms[1].order_number.value=sel_order;

document.forms[1].material.value=sel_material;

document.forms[1].days_activity.value=day_activity;

document.forms[1].submit();

}

</script>

<script language="JavaScript">

EPCM.subscribeEvent( 'urn:myOwnNameSpace', 'orderSelection', <%=jsFunctionSelect%> );

alert("orderdetail - subscribe orderSelection begin");

function <%=jsFunctionSelect%> ( evt ) {

toggleview.style.display="none";

}

</script>

Accepted Solutions (0)

Answers (4)

Answers (4)

andjelka_radjen
Participant
0 Kudos

Thanks a lot! I have it working now. It was a combination of doing what Geogi and Yoav suggested. I have awarded both of you some points. Thanks again.

andjelka_radjen
Participant
0 Kudos

BHARATHWAJ & Yoav,

Thanks for your suggestions. Unfortunately, neither of your suggestions worked. I tried both.

One thing I have noticed that is different between EP 5 and EP 6 is that when I use the document.forms[] statement I have had to reference them with document.forms[0] in the 1st iview, document.forms[1] in the second iview. In ep5, it treated each html document.forms[] independently and I used to use document.forms[0] regardless of which Iview I was in. I have no clue if this has anything to do with my problem but it's an observation I've made.

thanks

Angie.

Former Member
0 Kudos

Hi Angie

The namespace you are using for the clientdatabag and function are same.May be that can cause problem.

EPCM.storeClientData ( <b>'urn:myOwnNameSpace', 'processOrderDetail'</b>, order_material);

EPCM.raiseEvent( <b>'urn:myOwnNameSpace', 'processOrderDetail'</b>, order_material);

Change the variable 'processOrderDetail' to some other name in EPCM.storeClientData code.

There is no need to use both the client bag and parameter passing in EPCF. So you comment the EPCM.storeclientdata line of code and check whether it is working.

If you want the value in the client databag then use the EPCM.loadclientdata method in the

2nd iview as follows.

EPCM.raiseEvent( 'urn:myOwnNameSpace', 'processOrderDetail');

3rd iview as follows.

<script language="JavaScript">

EPCM.subscribeEvent( 'urn:myOwnNameSpace', 'processOrderDetail', <%=jsFunctionName1%> );

function <%=jsFunctionName1%> () {

var eventData = EPCM.loadclientdata('urn:myOwnNameSpace', 'processOrderDetail');

alert(eventData);

</script>

Regards

Geogi

Former Member
0 Kudos

Hi Angie,

Are all the iViews in URL Isolation method?

If they are, and it still doesn't work,

try changing the Isolation method to "Pumped (Deprecated)".

Hope that helps,

Yoav.

Former Member
0 Kudos

Hi,

How about hard coding the function name........?


EPCM.subscribeEvent( 'urn:myOwnNameSpace', 'processOrderDetail', <%=jsFunctionName%> ); 
function <%=jsFunctionName%> ( evt ) {

Regards

BHARATHWAJ