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,'#{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) {
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 +"\"?") ) {
theTable.remove(theRow);
if ( ElementToBeRefreshed != null ) { CAF.model(ElementToBeRefreshed).refresh(); };
return(true);
} else {
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?