var _THIS_control = { name: "", hasresponse: , controlset: "_THIS_", controlreset: "_THIS__", selectionParams: new Array() }; with(_THIS_control.selectionParams) { var temp = new Object().href="_THIS?frag-urlType=gatewayproxy/THIS_";push({name: "so.return.gateway", value: temp}); push({name: "so.return.domain", value: document.domain}); push({name: "so.return.m", value: "/fragments/common/dialog/callback.xts"}); push({name: "so.return.b_action", value: "xts.run"}); push({name: "md.displayOptions", value: "h1"}); push({name: " ", value: " ", type: "custom", customName: " "}); } _THIS_control .selectionParams.defaultStartLocations = new Array(); _THIS_control .selectionParams.defaultStartLocations.push(" "); _THIS_control .selectionParams.xPathToResponse = " "; _THIS_dependencyCleanup[" "] = new Array(); with(_THIS_dependencyCleanup[" "]) { push(" "); } var ccModalCallBack; var _THIS_currentCallbackResultPath; var _THIS_currentControl = null; function _THIS_reloadAfterSelectObject(response) { response = xmldecode(response); var form = _F_Form.find(_THIS_currentForm); var xml = new XMLBuilderLoadXMLFromString(response); if (form !== undefined && xml && _THIS_currentForm != "" && _THIS_currentControl) { var idNode = _F_DOM.selectSingleNode(xml, _THIS_currentCallbackResultPath); var id = _F_DOM.text(idNode); form["p_" + _THIS_currentControl.name].value = id; _THIS_resetDependents(form, _THIS_currentControl); _THIS_.addEventListener("fragment.retrieve.after","_THIS_closeSelectDialogEvent",false); form.submit(); } else { window.alert("BUG: no response or missing parameters"); } } function _THIS_closeSelectDialog() { _THIS_modalDialog.destroy(); _THIS_modalDialog = null; } function _THIS_closeSelectDialogEvent(evt) { if(evt.eventPhase == evt.AT_TARGET) { _THIS_closeSelectDialog(); _THIS_.removeEventListener("fragment.retrieve.after","_THIS_closeSelectDialogEvent",false); } } function _THIS_clearSelection(ctrl) { var form = _F_Form.find(_THIS_currentForm); if (form !== undefined) { if (_THIS_validateFields()) { _THIS_clearObject(form, ctrl); form.submit(); } } else { window.alert("BUG: no response or missing parameters"); } } function _THIS_clearObject(form, ctrl) { form["p_" + ctrl.name].value = ""; if (ctrl && ctrl.controlreset != '') { var ctrlset = $(ctrl.controlset); if (ctrlset && ctrlset.checked) { var ctrlreset = $(ctrl.controlreset); if (ctrlreset && ctrl.controlset != ctrl.controlreset) ctrlreset.checked=true; else ctrlset.checked=false; } } _THIS_resetDependents(form, ctrl); } function _THIS_resetDependents(form, ctrl) { if (_THIS_dependencyCleanup !== undefined && _THIS_dependencyCleanup[ctrl.name] != null) { var deps = _THIS_dependencyCleanup[ctrl.name]; for (var index=0;index < deps.length;index++) { var ctrl = window["_THIS_control" + deps[index]]; _THIS_clearObject(form, ctrl); } } } function _THIS_ccModalCallBack(cmd,sResponse) { var save = (cmd == 'ok' && sResponse); if(_THIS_currentControl) { if(_THIS_currentControl.controlset != "") { if (save) { $(_THIS_currentControl.controlset).checked = true; } else if (_THIS_currentControl.hasresponse != true && _THIS_currentControl.controlreset != "" && $(_THIS_currentControl.controlset).checked) { $(_THIS_currentControl.controlreset).checked = true; } } } if (save) { _THIS_reloadAfterSelectObject(sResponse); }else { setTimeout('_THIS_closeSelectDialog()', 1); } return; } function _THIS_chooseSelection(ctrl){ if (_THIS_validateFields()) { if (_THIS_modalDialog != null) { _THIS_modalDialog.destroy(); _THIS_modalDialog = null; } _THIS_validatedChooseSelection(ctrl); } } function _THIS_validatedChooseSelection(ctrl) { _THIS_currentControl = ctrl; var pickerParamsArray = _THIS_currentControl.selectionParams; var pickerFormAction = _THIS_currentControl.pickerFormAction; if ( !pickerFormAction ){ pickerFormAction = _THIS_defaultPickerAction; var additionalQuery = null; var queryIndex = pickerFormAction.indexOf('?'); if (queryIndex != -1){ additionalQuery = pickerFormAction.substring(queryIndex + 1); var currentPickerForm = getPickerForm("_THIS_pickerForm"); pickerFormAction = pickerFormAction.substring(0,queryIndex); } _THIS_currentControl.pickerFormAction = pickerFormAction; if (additionalQuery != null){ var params = additionalQuery.split('&'); for (var i = 0; i< params.length; ++i) { var param = params[i]; if (param.length > 0) { var eq_index = param.indexOf("="); var additionalParam = new Object(); additionalParam.type=""; if (eq_index != -1) { additionalParam.name = decodeURIComponent(param.substring(0, eq_index)); additionalParam.value = decodeURIComponent(param.substring(eq_index + 1)); } else { additionalParam.name = decodeURIComponent(param); additionalParam.value = ""; } pickerParamsArray.push(additionalParam); } } } } recreatePickerForm("_THIS_pickerForm", pickerFormAction); var currentPickerForm = getPickerForm("_THIS_pickerForm"); //now update the form with the correct elements for (var index=0; index < pickerParamsArray.length; index++) { if ("md.callBack" == pickerParamsArray[index].name || "md.backURL" == pickerParamsArray[index].name ) continue; var value = pickerParamsArray[index].value; //if it is custom then we should update the value based on the most current value for that property if (pickerParamsArray[index].type == "custom") { var custEl = $("_THIS_p_" + pickerParamsArray[index].customName); if (custEl != null) { value = getValueFromSimpleElement(custEl); createPickerInput(currentPickerForm,"picker_" + index, pickerParamsArray[index].name, value); } else if (!getSelectElements(pickerParamsArray[index].name, pickerParamsArray[index].customName, currentPickerForm)) { if (!getSelect1Elements(pickerParamsArray[index].name, pickerParamsArray[index].customName, currentPickerForm)){ getMultiLingualElements(pickerParamsArray[index].name, pickerParamsArray[index].customName, currentPickerForm, $("_THIS_Selector"), $("_THIS_" + pickerParamsArray[index].customName)); } } } else { createPickerInput(currentPickerForm, "picker_" + index, pickerParamsArray[index].name, value); } } ccModalCallBack = _THIS_ccModalCallBack; _THIS_currentCallbackResultPath = pickerParamsArray.xPathToResponse; var iframeStaticHeight = parseInt(xClientHeight() * .75); var iframeStaticWidth = parseInt(xClientWidth() * .75); //open the dialog to an empty url and submit the form as the form is targeted to the modal dialog var url = "about:blank"; if (_THIS_modalDialog == null) { _THIS_modalDialog = new ui_dialog("_THIS_modalDialogViewer", '', ui_dialog.style.BTN_NOBUTTONS | ui_dialog.style.CENTER | ui_dialog.style.IFRAME, -1, -1, iframeStaticWidth, iframeStaticHeight, _THIS_.div, url); } _THIS_modalDialog.show(); currentPickerForm.target = _THIS_modalDialog.iframeName; currentPickerForm.submit(); } if (window._THIS_modalDialog === undefined){ var _THIS_modalDialog = null; var _THIS_currentPickControl = null; }