LogOnHandler.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 2011
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. dojo.provide("LogOnHandler");
  13. dojo.declare("LogOnHandler", null, {
  14. constructor: function() {
  15. this.m_cvIdList = [];
  16. },
  17. handleLogon: function(cvId, promptInfoNamespace) {
  18. this.m_cvIdList.push(cvId);
  19. if(this.m_cvIdList.length == 1) {
  20. dojo["require"]("bux.dialogs.IFrameDialog"); //@lazyload
  21. var dialog = (promptInfoNamespace==null|| promptInfoNamespace.length==0) ?
  22. new bux.dialogs.LogonDialog({
  23. okHandler: GUtil.generateCallback(this.okHandler, [], this),
  24. cancelHandler: GUtil.generateCallback(this.cancelHandler, [], this)
  25. }):
  26. new bux.dialogs.LogonDialog({
  27. okHandler: GUtil.generateCallback(this.okHandler, [], this),
  28. cancelHandler: GUtil.generateCallback(this.cancelHandler, [], this),
  29. params: {"h_CAM_action": "logonAs", "CAMNamespace": promptInfoNamespace}
  30. });
  31. dialog.startup();
  32. dialog.show();
  33. }
  34. },
  35. okHandler: function() {
  36. for(var index = 0; index < this.m_cvIdList.length; ++index) {
  37. var cvId = this.m_cvIdList[index];
  38. var oCV = window["oCV" + cvId];
  39. // need to let chrome know the user logged on so they can refresh the user name and content tree
  40. if (index === 0 && oCV.getViewerWidget) {
  41. oCV.getViewerWidget().fireEvent("com.ibm.bux.widget.action", null, { action: "refreshAfterLogon" });
  42. }
  43. if (oCV.getRetryDispatcherEntry()) {
  44. oCV.getRetryDispatcherEntry().retryRequest();
  45. }
  46. else {
  47. var originalFormFields = oCV.getViewerWidget().getOriginalFormFields();
  48. if (originalFormFields) {
  49. oCV.executeAction("RetryRequest", originalFormFields);
  50. }
  51. }
  52. }
  53. this.m_cvIdList = [];
  54. },
  55. cancelHandler: function() {
  56. for(var index = 0; index < this.m_cvIdList.length; ++index) {
  57. var cvId = this.m_cvIdList[index];
  58. var oCV = window["oCV" + cvId];
  59. if (oCV.getRetryDispatcherEntry()) {
  60. oCV.getRetryDispatcherEntry().onCloseErrorDlg();
  61. }
  62. }
  63. this.m_cvIdList = [];
  64. }
  65. });
  66. IWidgetLogonhandler = new LogOnHandler();