Skip to Content

ecpm subscribe event not working

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>

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2005 at 06:06 AM

    Hi,

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

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

    Regards

    BHARATHWAJ

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2005 at 06:16 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 23, 2005 at 02:57 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • Posted on Sep 27, 2005 at 01:29 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.