working in the webclient too!
You need 2 things for this stuff to work:
1. A global var named 'core_gDialogResult'
2. This global method:
- Code: Select all
function core_DIALOG_show() {
//empty result global
globals.core_gDialogResult = null;
//get title
var vTitle = arguments[0];
//get message
var vMessage = arguments[1];
//get buttons in array
var vButtons = arguments[2];
//get dialog width
var vWidth = arguments[3];
if(!vWidth){
vWidth = 300; //set width to 300 as default
}
//get dialog height
var vHeight = arguments[4];
if(!vHeight){
vHeight = 120; //set height to 120 as default
}
//get form stylesheet
var vStyleSheet = arguments[5]
if(!vStyleSheet){
vStyleSheet = 'myDefaultCSS'; //set default stylesheet (not nessecary, but kinda nice to have)
}
//get message styleclass
var vStyleClass = arguments[6]
if(!vStyleClass){
vStyleClass = 'myDefaultStyleClass'; //set default message styleclass (not nessecary, but kinda nice to have)
}
var vDialogFormName = 'form_dlg';
//Check if dialogform exists in session, if so, remove the dialog form
if(history.removeForm(vDialogFormName)){
solutionModel.removeForm(vDialogFormName);
}
//Create dialogform
var vDialogForm = solutionModel.newForm(vDialogFormName, null, null, vStyleSheet, false, vWidth, vHeight);
vDialogForm.navigator = SM_DEFAULTS.NONE;
vDialogForm.scrollbars = SM_SCROLLBAR.HORIZONTAL_SCROLLBAR_NEVER | SM_SCROLLBAR.VERTICAL_SCROLLBAR_NEVER;
vDialogForm.borderType = 'EmptyBorder,0,0,0,0';
vDialogForm.RECORD_VIEW;
//Create form message label and insert the message
var vMessageLabel = vDialogForm.newLabel(vMessage, 20, 20, vWidth-20, vHeight-40);
vMessageLabel.transparent = true;
vMessageLabel.anchors = SM_ANCHOR.ALL;
vMessageLabel.styleClass = vStyleClass
vMessageLabel.verticalAlignment = SM_ALIGNMENT.TOP
//Create button method
var jButtonMethod = vDialogForm.newFormMethod('function BTN_click(event){ \
globals.core_gDialogResult = event.getElementName() ; \
application.closeFormDialog(); } ');
var vButton, vButtonName;
var vX = 20;
//Check if buttons are available in the arguments
if(vButtons.length > 0){
vX = vWidth - (110 * parseInt(vButtons.length)) - 15 ;
//Put the button(s) on the form
for(var i in vButtons){
vButtonName = vButtons[i];
vButton = vDialogForm.newButton(vButtonName, vX, vHeight-52, 100, 22,jButtonMethod);
vButton.name = vButtonName;
vButton.anchors = SM_ANCHOR.SOUTH | SM_ANCHOR.EAST
vX = vX+110;
}
}
//Show the formInDialog!
application.showFormInDialog(vDialogFormName,-1,-1,vWidth,vHeight,vTitle,false,false,vDialogFormName)
}
This is how to use the method and show the dialog:
(dialogwidth,dialogheight,'stylesheet','message styleclass' are optional arguments, btw)
- Code: Select all
globals.core_DIALOG_show('title','message',[button1,button2,ect],dialogwidth,dialogheight,'stylesheet','message styleclass')
if(globals.core_gDialogResult){
//do something
}
Offcourse you can modify the global method and add all kinds of stuff in the dialog, and use specific dialogs for specific purposes,
but this could be a nice way to start.
Enjoy!