In a multipage (ARIS 9.7) dialog I want to validate the input when the OK button is pressed. In case of invalid data the dialog may not be closed. This leads to the following questions.
1. Is there a way to create an eventhandler for the OKbutton ( 'this.OK_pressed = function()' does not work)) ?
2. Is there a way to prevent the dialog from closing when the OK-button is pressed (assuming that there is a solution for the first question), and how do I close the dialog 'manually'?
3. Is it possible to prevent automatic generation of the Ok and Cancel button?
Hi Robert,
Thanks for the suggestion. But Dialogs.show() and Dialogs.createUserDialog() are deprecatedas so we are forced to use the Dialogs.showDialog() function. Using the example in the help and overriding the .getResult() function in the dialog gives me the output I need, but then I cannot determine whether the OKButton or the Cancel button was hit.
When I do not override the getResult() it gives me an integer to identify the button used, I have not found out yet how to get the values from the dialog after the dialog has closed while using the Dialogs.showDialog() function.
Here is a simple example of what I need. Can you help me out with the two statements at the bottom?
function myDialog() { this.getPages = function() { var iDialogTemplate0 = Dialogs.createNewDialogTemplate(569,305, 'Page1'); iDialogTemplate0.TextBox(66, 108, 372, 15, 'NAME'); return [iDialogTemplate0]; } this.init = function(aPages) { this.dialog.getPage(0).getDialogElement("NAME").setText("Default"); } this.isInValidState = function(pageNumber) { var name = this.dialog.getPage(pageNumber).getDialogElement("NAME").getText(); if (name == "" || name === undefined) { return false; } return true; } this.onActivatePage = function(pageNumber) { } this.canFinish = function(pageNumber) { return true; } this.canChangePage = function(pageNumber) { return true; } this.canGotoNextPage = function(pageNumber) { return true; } this.canGotoPreviousPage = function(pageNumber) { return true; } this.onClose = function(pageNumber, bOk) { } this.getResult = function() { return this.dialog.getPage(0).getDialogElement("NAME").getText(); } } function main() { var Result = Dialogs.showDialog(new myDialog(), Constants.DIALOG_TYPE_WIZARD, "M@ CopyView"); //var buttonPressed = ??? //var enteredName = ??? } main();
Just found out. If I do not override getResult() I get the integer that identifies the button used.
To get the data i can define a global object DialogData and fill it in the onClose() function. After that I can use the DialogData object to extract the entered data when the dialog has closed. You can also use the boolean bOk to pass some kind of status to the main script.
this.onClose = function(pageNumber, bOk) { DialogData = { Name : dialog.getPage(0).getDialogElement("NAME").getText(), nextitem : ....... } }