IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  How to remove Listener

    Posted 05/06/11 03:42 PM

    Hi read the API docs that contains removeActionCompleteListener but it seems that it doesnt work. Here’s how I tried to remove a listener

    CAF.model('#{activePageBean.clientIds['V_DV_MD_FECHARCONFIRM_BTN_ID']}').removeActionCompleteListener
    (CAF.model('#{activePageBean.clientIds['V_DV_MD_FECHARCONFIRM_BTN_ID']}').listActionCompleteListeners()[0]); 
    
    CAF.model('#{activePageBean.clientIds["V_DV_MD_FECHARCONFIRM_BTN_ID"]}').addActionCompleteListener( 
    function callBackFecharDecVenda(commandID) { 	
    
    alert("hereeeeeeeeeee");
    
    }
    );

    Can you provide me some working example

    Thanks


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods


  • 2.  RE: How to remove Listener

    Posted 05/06/11 06:55 PM

    There is a more reliable way of removing listeners other than just removing the first in the list. Obtain a reference to the call back function like this:

    function doSomething(){ 
    //Your logic 
    } 
    
    //add a reference
    CAF.model("#{activePageBean.clientIds['hidden']}").addActionCompleteListener(doSomething); 
    
    //remove the reference
    CAF.model("#{activePageBean.clientIds['hidden']}").removeActionCompleteListener(doSomething); 

    Hope this helps.
    –mark


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods


  • 3.  RE: How to remove Listener

    Posted 05/06/11 07:20 PM

    Hi,

    I´ve tried what you wrote and It doesn’t work.

    If you press the button it will refresh the area that contains the script that adds and removes the listener. As the listener is never remover for each time the area is refreshed you will see +1 alert dialog

    Thanks
    TestProject.zip (14.9 KB)


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods


  • 4.  RE: How to remove Listener

    Posted 05/06/11 07:42 PM

    Hi Herve,

    You will want to store the function object in some global variable so you use the same reference when adding and removing. What your test portlet is doing is redeclaring the function every time the page fragment is rendered, so it is using different function references on each render.

    For example, do something like this:

    //remove the previous reference 
    CAF.model("#{activePageBean.clientIds['button']}").removeActionCompleteListener(window.doSomethingFn); 
    
    //re-declare the function and store it on the window object
    window.doSomethingFn = function(){ 
    alert("hereeeeeeeee");
    } 
    
    //add a reference 
    CAF.model("#{activePageBean.clientIds['button']}").addActionCompleteListener(window.doSomethingFn); 

    #webMethods
    #MWS-CAF-Task-Engine
    #webMethods-BPMS


  • 5.  RE: How to remove Listener

    Posted 05/06/11 07:42 PM

    Thanks for the test project. I think the problem you’re having is that you have attached an Action Complete Listener to a button, but that Listener “lives” inside of a Panel that is being refreshed upon completion.

    Is it possible to have that Javascript live outside of the panel that is being refreshed?


    #MWS-CAF-Task-Engine
    #webMethods-BPMS
    #webMethods


  • 6.  RE: How to remove Listener

    Posted 05/06/11 08:00 PM

    In my case I can not put the script outside the refreshed area.

    I’ve tried the script that was suggested and It also contains the problem.

    I thing that the API implementation should contains some problem because if I also try to get the listeners added the response is also null or 0
    alert(CAF.model(‘#{activePageBean.clientIds[‘button’]}’).listActionCompleteListeners().length);


    #webMethods-BPMS
    #webMethods
    #MWS-CAF-Task-Engine


  • 7.  RE: How to remove Listener

    Posted 05/31/11 09:34 AM

    Hello,
    I’m facing the same problem currently with version 7.1.3.
    I’ve tried the proposed solutions, but unfortunately with no success.
    The previously registered listeners could not be removed, resulting in multiple executin of the same logic.
    So I am curious, did you manage to find a workaround for this issue?

    Thanks.


    #webMethods-BPMS
    #MWS-CAF-Task-Engine
    #webMethods