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.

 View Only
  • 1.  Using undocumented JavaScript CAF methods

    Posted Thu September 15, 2011 03:21 PM

    Hi,

    I needed to add a confirmation dialog to a DeleteRowButton (as I describe in http://tech.forums.softwareag.com/viewtopic.php?t=24646 ) so I created the following code in a Script Block to execute the row deletion to be called on the OnClick client-side event of a Async Command Icon:

    
    // Send the actual ID of the DOM object as in
    // deleteRoleButConfirmBefore(this,'#&#123;caf:cid("<control>")}');
    //
    // the confirmation is using the value in the innerHTML of the columnIndexOfDataForConfirmation td 
    // element of the row
    function deleteRoleButConfirmBefore(Role,columnIndexOfDataForConfirmation,ElementToBeRefreshed) &#123;
    
    if ( Role == null || Role.id == null || columnIndexOfDataForConfirmation == null ) return(false);
    
    // This will only work if the this object is at the bottom of the path table>tbody>tr>td (table is the 4th ancestor)
    // var theTable=CAF.model(Role.parentNode.parentNode.parentNode.parentNode.id);
    // var theRow=CAF.model(theTable.findParentItem(Role.id));  
    
    // This might break as CAF.Table.getTableIdFromRowId seems to a private method (does not appear on the documentation)
    var theRow      = CAF.model(CAF.Table.getTableIdFromRowId(Role.id));   
    if ( theRow == null ) return(false);
    
    var theTable    = CAF.model(CAF.Table.getTableIdFromRowId(theRow.id));
    if ( theTable == null ) return(false);
    
    // innerText for IE, textContent for standards compliance 
    // http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent
    var theRoleName = theRow.element.cells[columnIndexOfDataForConfirmation].textContent ||
    theRow.element.cells[columnIndexOfDataForConfirmation].innerText;
    if ( theRoleName == null ) return(false);
    
    if ( confirm("Are you sure want to delete the role \"" + theRoleName +"\"?") ) &#123;
    theTable.remove(theRow);
    if ( ElementToBeRefreshed != null ) &#123; CAF.model(ElementToBeRefreshed).refresh(); };
    return(true);
    } else &#123;
    return(false);
    }; 
    };

    My problem is that I am using the undocumented JavaScript CAF methods CAF.Table.getTableIdFromRowId and remove for which I cannot find any documentation but both have been mentioned in this forum by SAG staff.

    Is it ok to use these functions? Where can I find their definitions?
    Or do I risk the possibility of the code being broken in the next fixes or versions?


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


  • 2.  RE: Using undocumented JavaScript CAF methods

    Posted Thu September 15, 2011 04:28 PM

    Why not just add another parameter into your function?

    You have this comment:
    deleteRoleButConfirmBefore(this,‘#{caf:cid(“”)}’);

    can you extend the function to be:

    deleteRoleButConfirmBefore(this,'#&#123;caf:cid("<control>")}','#&#123;caf:cid("<table>")}'); 

    Regards,
    –mark


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


  • 3.  RE: Using undocumented JavaScript CAF methods

    Posted Thu September 15, 2011 05:33 PM

    That only removes one of the calls, I still have to use getTableIdFromRowId to get the row’s ID so I can use its ‘remove’ method.


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


  • 4.  RE: Using undocumented JavaScript CAF methods

    Posted Thu September 15, 2011 06:03 PM

    There is an easier way to get the Row Model. Have a look at the Designer On-line help section called: ‘CAF.Table.Row.Model’

    Regards,
    –mark


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


  • 5.  RE: Using undocumented JavaScript CAF methods

    Posted Fri September 16, 2011 10:40 AM

    Would you mind supplying an example?

    I tried CAF.Table.Row.Model.prototype.getControlId(this.id) on onClick Client-Side action of the button but it returns again the button ID and not the Row ID.

    Thank you.


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


  • 6.  RE: Using undocumented JavaScript CAF methods

    Posted Tue September 20, 2011 05:10 PM

    Oh boy, i owe you an apology. Your approach was correct and i’ve filed an internal defect to ensure that the APIs: getTableIdFromRowId and remove will be documented and supported.

    Please accept my apologies.
    Regards,
    –mark


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


  • 7.  RE: Using undocumented JavaScript CAF methods

    Posted Tue September 20, 2011 06:33 PM

    That’s ok :wink:

    At least I am on the right track. :slight_smile:


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