123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| BI and PM: prmt
- *| (C) Copyright IBM Corp. 2002, 2013
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- /*
- CSelectDataSourceSignon.js
- This script is used to allow users to select a connection and signon for a datasource
- */
- //Constructor to create a select datasource signon component
- //Constructor to create a checkboxlist component
- // oDataSourceConnection: the form control used to for the data source connection value
- // oDataSourceSignon: the form control used for the data source signon value
- // oUsername: the form control used for the user name
- // oPassword: the form control used for the password
- // oSubmit: the form control to submit selections to the server
- // oUseSignonDefault: form control used to set whether choosing signons should be the default
- // sSubmitType: 'default' will submit as a standard form
- // 'XML' will convert the submission to XML and submit
- // bSignonForCube: set to true if this signon is for a password protected cube (credentials are differents in this case). Default = false
- // bOKButtonPromptTypeIsNext this is used to determine whether this should do a next or a finish to conform with the onClick of the OKButton of the defaultpagefooter
- function CSelectDataSourceSignon(oDataSourceConnection, oDataSourceSignon, oUsername, oPassword, oSubmit, oUseSignonDefault, sSubmitType, oRadioList, oImgTest, bSignonForCube, sCVId, sPromptId, bOKButtonPromptTypeIsNext)
- {
- this.setCVId(sCVId);
- this.m_oDataSourceConnection = oDataSourceConnection;
- this.m_oDataSourceSignon = oDataSourceSignon;
- this.m_oUsername = oUsername;
- this.m_oPassword = oPassword;
- this.m_oSubmit = oSubmit;
- this.m_bValid = false;
- this.m_sSubmitType = sSubmitType;
- this.m_bUseSignon = true;
- this.m_bOKButtonPromptTypeIsNext = (bOKButtonPromptTypeIsNext === true);
- this.m_bSignonForCube = (bSignonForCube === true);
- if (typeof oRadioList != K_PRMT_sUNDEFINED) {
- this.m_oRadioList = oRadioList;
- }
- else {
- this.m_oConnectionRadioList = null;
- }
- if (typeof oImgTest != K_PRMT_sUNDEFINED) {
- this.m_oImgTest = oImgTest;
- }
- else {
- this.m_oImgTest = null;
- }
- this.m_sPromptId = sPromptId;
- //skin folder
- this.m_sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN);
- if (this.m_oImgTest != null)
- {
- this.m_oImgErrorFalse= new Image();
- this.m_oImgErrorFalse.src = this.m_sSkin + "/prompting/images/error_timed_small_off.gif";
- this.m_oImgErrorTrue = new Image();
- this.m_oImgErrorTrue.src = this.m_sSkin + "/prompting/images/error_timed_small.gif";
- }
- //use a User Id and Password or a Signon
- //default use Signon = 'true';
- if (oUseSignonDefault)
- {
- if (oUseSignonDefault.value == 'false')
- {
- this.m_bUseSignon = false;
- }
- }
- // Event handlers
- PRMTUtils.f_addEvent( this.m_oUsername, "keypress", this.keyPress.bind(this) );
- PRMTUtils.f_addEvent( this.m_oPassword, "keypress", this.keyPress.bind(this) );
- this.checkData();
- }
- CSelectDataSourceSignon.prototype = new CPromptControl();
- //render the validated state
- function CSelectDataSourceSignon_checkPass()
- {
- if ((this.m_oImgTest != null) && (this.m_oImgTest.src != this.m_oImgErrorFalse.src))
- {
- this.m_oImgTest.src = this.m_oImgErrorFalse.src;
- }
- this.notify(gPASS, this);
- }
- //render the validation error state
- function CSelectDataSourceSignon_checkFail()
- {
- if (this.m_oImgTest != null)
- {
- this.m_oImgTest.src = this.m_oImgErrorTrue.src + '?' + Math.random();
- }
- this.notify(gFAIL, this);
- }
- //validate the input into the control
- function CSelectDataSourceSignon_checkData()
- {
- this.m_bValid = true;
- if (this.m_oRadioList != null)
- {
- this.m_bValid = false;
- if (this.m_oRadioList.checked == true) {
- this.m_bValid = true;
- }
- else
- {
- for (var i = 0; i < this.m_oRadioList.length; i++)
- {
- if (this.m_oRadioList[i].checked) {
- this.m_bValid = true;
- }
- }
- }
- }
- if (this.m_bValid) {
- this.checkPass();
- }
- else {
- this.checkFail();
- }
- this.notify((this.m_bValid ? gPASS : gFAIL), this);
- return this.m_bValid;
- }
- function CSelectDataSourceSignon_preProcess()
- {
- if (this.m_sSubmitType == K_PRMT_sXML && this.m_oSubmit)
- {
- this.m_oSubmit.value = '<selectChoices><selectOption useValue="' + sXmlEncode(this.sGetValue()) + '" selected="true"/></selectChoices>';
- }
- }
- function CSelectDataSourceSignon_sGetPersistValue()
- {
- var v_sResult = K_PRMT_sEMPTY;
- var v_oPersistCheckBox = $( "oPersist" + this.m_sPromptId );
- if (v_oPersistCheckBox && v_oPersistCheckBox.checked) {
- v_sResult += ' persist="true"';
- }
- return v_sResult;
- }
- //return the selection in the following XML format:
- //
- // <credential>
- // <dataSourceConnection>...searchPath to connection...</dataSourceConnection>
- // <dataSourceSignon>...searchPath to signon...</dataSourceSignon>
- // <username> ... </username>
- // <password> ... </password>
- // </credential>
- function CSelectDataSourceSignon_sGetValue()
- {
- var sCredential = K_PRMT_sEMPTY;
- var v_sPersist = this.sGetPersistValue();
- sCredential += "<credential" + v_sPersist + ">";
- //create credential elements
- //data source connection
- var v_oConnectionName = K_PRMT_sEMPTY;
- var v_oConnectionNameElem = $( "oConnectionName" + this.m_sPromptId );
- if (v_sPersist.length > 0 && v_oConnectionNameElem && v_oConnectionNameElem.value) {
- v_oConnectionName = ' name="' + v_oConnectionNameElem.value +'"';
- }
- sCredential += "<dataSourceConnection" + v_oConnectionName + ">";
- if (this.m_oDataSourceConnection != null)
- {
- sCredential += this.m_oDataSourceConnection.value;
- }
- sCredential += "</dataSourceConnection>";
- if (this.m_bUseSignon == true)
- {
- //data source signon
- sCredential += "<dataSourceSignon>";
- if (this.m_oDataSourceSignon != null)
- {
- sCredential += this.m_oDataSourceSignon.value;
- }
- sCredential += "</dataSourceSignon>";
- //user name
- sCredential += "<username/>";
- //password
- sCredential += "<password/>";
- }
- else
- {
- //data source signon
- sCredential += "<dataSourceSignon/>";
- //user name
- sCredential += "<username>";
- if (this.m_oUsername != null)
- {
- sCredential += this.m_oUsername.value;
- }
- sCredential += "</username>";
- if (this.m_bSignonForCube) {
- //cubePassword
- sCredential += "<cubePassword>";
- if (this.m_oPassword != null)
- {
- sCredential += sXmlEncode(this.m_oPassword.value);
- }
- sCredential += "</cubePassword>";
- }
- else {
- //password
- sCredential += "<password>";
- if (this.m_oPassword != null)
- {
- sCredential += sXmlEncode(this.m_oPassword.value);
- }
- sCredential += "</password>";
- }
- }
- sCredential += "</credential>";
- return sCredential;
- }
- function CSelectDataSourceSignon_setDataSourceConnection(s)
- {
- this.m_oDataSourceConnection.value = s;
- }
- function CSelectDataSourceSignon_setDataSourceSignon(s)
- {
- this.m_oDataSourceSignon.value = s;
- }
- function CSelectDataSourceSignon_setbUseSignon(sUseSignon)
- {
- if (sUseSignon == 'true')
- {
- this.m_bUseSignon = true;
- }
- else if (sUseSignon == 'false')
- {
- this.m_bUseSignon = false;
- }
- else
- {
- this.m_bUseSignon = sUseSignon;
- }
- }
- function CSelectDataSourceSignon_keyPress()
- {
- var v_oEvt = ( arguments && arguments.length ? arguments[arguments.length-1] : null );
- if ( v_oEvt )
- {
- var keyCode = (v_oEvt.keyCode) ? v_oEvt.keyCode : v_oEvt.which;
- if ( keyCode == '13' )
- {
- var oCV = this.getCV();
- if ( oCV && (typeof oCV.canSubmitPrompt == K_PRMT_sFUNCTION) && oCV.canSubmitPrompt() && (typeof oCV.promptAction == K_PRMT_sFUNCTION))
- {
- // If instructed to do so submit the form using next action
- if (this.m_bOKButtonPromptTypeIsNext == true)
- {
- oCV.promptAction(K_ACTION_NEXT);
- }
- else // do the old thing cause it doesn't have a next button
- {
- oCV.promptAction(K_ACTION_FINISH);
- }
- }
- return PRMTUtils.F_StopEvent( v_oEvt );
- }
- }
- return true;
- }
- //Prototypes to assign methods to new instances of the object
- CSelectDataSourceSignon.prototype.preProcess = CSelectDataSourceSignon_preProcess;
- CSelectDataSourceSignon.prototype.checkPass = CSelectDataSourceSignon_checkPass;
- CSelectDataSourceSignon.prototype.checkFail = CSelectDataSourceSignon_checkFail;
- CSelectDataSourceSignon.prototype.checkData = CSelectDataSourceSignon_checkData;
- CSelectDataSourceSignon.prototype.keyPress = CSelectDataSourceSignon_keyPress;
- CSelectDataSourceSignon.prototype.sGetPersistValue = CSelectDataSourceSignon_sGetPersistValue;
- CSelectDataSourceSignon.prototype.sGetValue = CSelectDataSourceSignon_sGetValue;
- CSelectDataSourceSignon.prototype.setDataSourceConnection = CSelectDataSourceSignon_setDataSourceConnection;
- CSelectDataSourceSignon.prototype.setDataSourceSignon = CSelectDataSourceSignon_setDataSourceSignon;
- CSelectDataSourceSignon.prototype.setbUseSignon = CSelectDataSourceSignon_setbUseSignon;
|