123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- /****************************************************************
- ** Licensed Materials - Property of IBM
- **
- ** BI and PM: qs
- **
- ** (C) Copyright IBM Corp. 2001, 2015
- **
- ** US Government Users Restricted Rights - Use, duplication or
- ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *****************************************************************/
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved.
- // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
- var FORM_SUBMISSION_ERROR = -1;
- var FORM_SUBMISSION_FAILURE = 0;
- var FORM_SUBMISSION_SUCCESS = 1;
- function CFormManager()
- {
- this.m_oWindowMgr = null;
- if (typeof goApplicationManager != "undefined" && goApplicationManager instanceof CApplicationManager)
- {
- this.m_oWindowMgr = goApplicationManager.getWindowManager();
- }
- else if (typeof goDialogManager != "undefined" && goDialogManager instanceof CDialogManager)
- {
- this.m_oWindowMgr = goDialogManager.getWindowManager();
- }
- else if (typeof goWindowManager != "undefined" && goWindowManager instanceof CWindowManager)
- {
- this.m_oWindowMgr = goWindowManager;
- }
- };
- CFormManager.prototype.getFormElement = function (sFormName, sFormElementName)
- {
- var oFormElt = document.forms[sFormName].sFormElementName;
- if (typeof oFormElt != "undefined")
- {
- return oFormElt;
- }
- else
- {
- return null;
- }
- };
- CFormManager.prototype.createForm = function (oDocumentElt, bUsePost, sFormAction)
- {
- if (typeof oDocumentElt == "undefined")
- {
- oDocumentElt = document;
- }
- try
- {
- var oForm = oDocumentElt.createElement("FORM");
- if ((typeof bUsePost == "undefined") || (typeof bUsePost != "undefined") && (bUsePost === true))
- {
- oForm.method = "POST";
- }
- else
- {
- oForm.method = "GET";
- }
- if ((typeof sFormAction != "undefined") && (sFormAction !== null) && (sFormAction !== ""))
- {
- oForm.action = sFormAction;
- }
- oForm.target = "_self";
- return oForm;
- }
- catch (e)
- {
- return null;
- }
- };
- CFormManager.prototype.createHiddenInput = function (oDocumentElt, oForm, sId, sName, sValue)
- {
- if (typeof oDocumentElt == "undefined")
- {
- oDocumentElt = document;
- }
- try
- {
- var oInput = oDocumentElt.createElement("INPUT");
- oInput.setAttribute("type", "hidden");
- if (typeof sName == "string")
- {
- if (typeof sId != "string")
- {
- sId = sName;
- }
- oInput.setAttribute("name", sName);
- }
- if (typeof sId == "string")
- {
- oInput.setAttribute("id", sId);
- }
-
-
-
- switch (typeof sValue)
- {
- case "string":
- case "number":
- oInput.setAttribute("value", sValue);
- break;
- case "boolean":
- var sBooleanValue = (sValue === true) ? "true" : "false";
- oInput.setAttribute("value", sBooleanValue);
- break;
- }
- if (typeof oForm == "object" && oForm !== null)
- {
- oForm.appendChild(oInput);
- }
- return oInput;
- }
- catch (e)
- {
- return null;
- }
- };
- CFormManager.prototype.setupDialogForm = function (aParams, bUsePost)
- {
- if ((typeof bUsePost == "undefined") || (typeof bUsePost != "undefined" && bUsePost === true))
- {
- if (this.m_oWindowMgr !== null)
- {
-
- var oDialogFrame = this.m_oWindowMgr.getDialogFrame();
- var oForm = this.createForm(oDialogFrame.document, bUsePost, this.m_oWindowMgr.getApplicationManager().get("scriptEngine"));
- if (oForm !== null)
- {
- oForm.style.margin = "0px";
- var oBody = oDialogFrame.document.getElementsByTagName("BODY");
- if (oBody !== null && oBody[0] !== null)
- {
- oBody = oBody[0];
- }
- else
- {
- oBody = oDialogFrame.document.documentElement;
- }
- oBody.appendChild(oForm);
-
-
- while (oForm.hasChildNodes())
- {
- oForm.removeChild(oForm.firstChild);
- }
- if (typeof aParams == "object" && aParams instanceof Array)
- {
-
- if (cafContextId !== "")
- {
- aParams["ui.cafcontextid"] = cafContextId;
- }
- aParams["b_action"] = "xts.run";
-
- for (var counter in aParams)
- {
- this.createHiddenInput(oDialogFrame.document, oForm, counter, counter, aParams[counter]);
- }
- }
- return oForm;
- }
- }
- }
- else
- {
- }
- return null;
- };
- CFormManager.prototype.submitForm = function (oFormObj)
- {
- if (typeof oFormObj == "object")
- {
- try
- {
- oFormObj.submit();
- }
- catch (e)
- {
- return FORM_SUBMISSION_FAILURE;
- }
- return FORM_SUBMISSION_SUCCESS;
- }
- return FORM_SUBMISSION_ERROR;
- };
|