Symantec IGA

  • 1.  How to restrict Wildcard characters in IdM search screen?

    Posted Feb 09, 2017 03:37 AM

    I am working on a Identity Manager(version 12.6.5) search screen where the user will enter his details like UniqueID, First and Last name and if there is an exact match then results are displayed.

     

    For this I have customized Identity Manager out of the box User search screen which fulfills the requirement (to most of the extent) but the screen also support wildcard character search which is something I don't want.

     

    Is there any way through which one can restrict wild card characters in the search screen? 

     

    Does anyone have any idea/solution please?

     

    Thank you,

    Vijay



  • 2.  Re: How to restrict Wildcard characters in IdM search screen?
    Best Answer

    Posted Feb 09, 2017 12:11 PM

    There is currently no way of disabling wildcard searches in IDM. Have you tried a validation script on the search screen? Although, we can't help writing it I can say that other customers have implimented a solution like this.



  • 3.  Re: How to restrict Wildcard characters in IdM search screen?

    Posted Feb 09, 2017 01:08 PM

    You can restrict Wildcard characters by adding custom java script, updating standard_search.jsp  out of box jsp page. See below pseudo code, let me know if need more details or example code.

     

    Example:

     

    @ iam_im.ear/user_console.war/app/page/screen/standard_search.jsp file

     

     

    var captureke=10;

    function customImOnKeyPress(evnt) {

    }

     

    var wP;

    function customImOnSubmit()

    {

     

     

    }



  • 4.  RE: Re: How to restrict Wildcard characters in IdM search screen?

    Broadcom Employee
    Posted Dec 16, 2021 12:24 PM
      |   view attached
    This is a sample task.js that prevents uid=* searches:

    var imScroll = false;
    var imScrollX = 0;
    var imScrollY = 0;
    var imExistingOnSubmitHandler = null;
    var global = this;
    var imDefaultActionEnabled = true;
    var imDefaultAction = null;
    var imSaveDefaultAction = null;
     
     
    function imDisableDefaultAction() {
      imDefaultActionEnabled = false;
    }
     
    function imEnableDefaultAction() {
      imDefaultActionEnabled = true;
    }
     
    function imSetDefaultAction(action) {
      imEnableDefaultAction();
      imDefaultAction = action;
    }
     
    function imActionOnFocus(action) {
      imSaveDefaultActionEnabled = imDefaultActionEnabled;
      imSaveDefaultAction = imDefaultAction;
      imEnableDefaultAction();
      imDefaultAction = action;
    }
     
    function imActionOnBlur() {
      imDefaultActionEnabled = imSaveDefaultActionEnabled;
      imDefaultAction = imSaveDefaultAction;
    }
     
     
    function imOnLoad(evnt) {
      // add submit handler
      if (document.forms.main) {
        imAddEvent(document.forms.main, "submit", imOnSubmit);
      }
      // auto scroll
      if (imScroll) {
          imScrollTo(imScrollX, imScrollY);
      }
    }
     
    function imOnChange() {
      imActiveChanges = true;
    }
     
    var imIgnoreChangeFields = new Array();
     
    function imAddIgnoreChangeField(fieldid) {
    imIgnoreChangeFields[fieldid] = true;
    }
    function imAddOnChangeHandlers() {
      if (document.forms.length > 0) {
        if (document.forms.main) {
          var fields = document.forms.main.elements;
          for (i = 0; i < fields.length; i++) {
            if (!imIgnoreChangeFields[fields[i].id]) {
              imAddEvent(fields[i], "change", imOnChange);
            }
          }
        }
      }
    }
     
    var captureke=10;
     
    function customImOnKeyPress(evnt) {
    }
     
    function imOnKeyPress(evnt) {
     
      if (imDefaultAction == null) {
        return true;
      }
      
      if (!evnt) {
        var evnt = window.event;
      }
      
      if (!evnt) {
        return true;
      }
      
      var keycode;
     
      if (evnt.keyCode) {
        keycode = evnt.keyCode;
      } else if (evnt.which) {
        keycode = evnt.which;
      } else {
        return true;
      }
     
      var targ;
      if (evnt.target) {
        targ = evnt.target;
      } else if (evnt.srcElement) {
        targ = evnt.srcElement;
      }
      if (targ.nodeType == 3) { // safari
        targ = targ.parentNode;
      }
     
      var elem;
      if (targ.tagName) {
        elem = targ.tagName.toLowerCase();
      }
      
      var link = false;
      if (elem == 'a') {
        link = true;
      }
      if (link) {
        return true;
      }
      
      var button = false;
      if (elem == 'textarea' ||
          elem == 'button' ||
      elem == 'image' ||
         (elem == 'input' && (targ.getAttribute('type') == 'submit' ||
                      targ.getAttribute('type') == 'button' ||
                              targ.getAttribute('type') == 'image') ) ) {
        button = true;
      }
      if (button) {
        return true;
      }
      
      if (keycode == 13) { // ENTER key
    waitMessage = false;
    if (imWaitMessageActions[imDefaultAction]) {
          waitMessage = true;
    }
        imSubmitAction(imDefaultAction, '0', waitMessage);
        return false;
      } else {
        return true;
      }
    }
     
    var imWaitMessageActions = new Array();
    function imSetWaitMessageAction(action) {
      imWaitMessageActions[action] = true;
    }
     
    var imIsSubmitted = false;
    function imOnSubmit(evnt) {
      if (typeof jsFacesContext != 'undefined') {
          _viewroot_ = jsFacesContext.getViewRoot()
          if (_viewroot_) {
              _form_ = _viewroot_.findComponent('main');
              if (_form_) {
                  if (!_form_.isValid()) {
                      return false;
                  }
              }
          }
      }
      if (window.event) {
        evnt = window.event;
      }
      if (imIsSubmitted) {
        if (evnt && evnt.preventDefault) {
          evnt.stopPropagation();
          evnt.preventDefault();
        }
        return false;
      }
      imSaveScrollPosition();
      imIsSubmitted = true;
     
      // make sure that disabled is set for any readonly form fields so that they don't get submitted
      if (document.forms.length > 0) {
        if (document.forms.main) {
          var fields = document.forms.main.elements;
          for (i = 0; i < fields.length; i++) {
            if (fields[i].readOnly) {
              fields[i].disabled = true;
            }
          }
        }
      }
      
      return true;
    }
     
    function imSaveScrollPosition() {
      var scrollX = document.getElementById('ScrollPosX');
      if (scrollX != null) {
          scrollX.value = imGetScrollX();
      }
      var scrollY = document.getElementById('ScrollPosY');
      if (scrollY != null) {
          scrollY.value = imGetScrollY();
      }
    }
     
    function imScrollTo(x, y) {
      window.scrollTo(x, y);
    }
     
    function imGetScrollX() {
      var scrollX = 0;
      if (window.pageXOffset) {
        // ns/moz
        scrollX = window.pageXOffset
      } else if (document.documentElement && document.documentElement.scrollLeft) {
        // ie standards
        scrollX = document.documentElement.scrollLeft;
      } else if (document.body) {
        // dom
        scrollX = document.body.scrollLeft;
      }
      return scrollX;
    }
     
    function imGetScrollY() {
      var scrollY = 0;
      if (window.pageYOffset) {
        // ns/moz
        scrollY = window.pageYOffset
      } else if (document.documentElement && document.documentElement.scrollTop) {
        // ie standards
        scrollY = document.documentElement.scrollTop;
      } else if (document.body) {
        // dom
        scrollY = document.body.scrollTop;
      }
      return scrollY;
    }
     
    function imGetClientHeight() {
      var myHeight = 0;
      if ( typeof( window.innerHeight ) == 'number' ) {
        //Non-IE
        myHeight = window.innerHeight;
      } else if( document.documentElement && document.documentElement.clientHeight ) {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && document.body.clientHeight ) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
      }
      return myHeight;
    }
     
    function imGetClientWidth() {
      var myWidth = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
      } else if( document.documentElement && document.documentElement.clientWidth ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
      } else if( document.body && document.body.clientWidth ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
      }
      return myWidth;
    }
     
    //submits the form with the specified action
    //action – action to submit
    //value – value for action (default='0')
    //showmsgbox – show a wait message during submission (default=false)
    //message – message to display to user (default=imWaitMessage)
    function imSubmitAction(action, value, showmsgbox, message) {
      
      if (imOnSubmit()) {
        var elem = document.createElement("input");
        elem.type = "hidden";
        elem.name = action;
        elem.id = "submit.action";
        if (value == null) {
        value = "0";
      }
        elem.value = value;
        document.forms.main.appendChild(elem);
     
        if (showmsgbox) {
          imMessage(message);
    var valor = document.getElementsByName("Filter.0.Value")[0].value;
     
    var task = new Ext.util.DelayedTask(function(){
          });
     
    if (valor=="*") { Ext.Msg.alert('Error', 'acota la busqueda'); return true; } else 
       document.forms.main.submit();
     
     
          task.delay(200);
          return false;
        }
        
        document.forms.main.submit();
        return false;
      }
    }
     
    var keyCode = 0;
    var keyDownCode = 38 // keyboard keydown arrow key code
    var keyUpCode = 40 // keyboard keyup arrow key code
     
    function imOnSubmitAction(action)
    {
    // do not submit the action if the key down or key up arrow keys are used to change the item in combo
    if (keyCode != keyDownCode && keyCode != keyUpCode)
        {
    imSubmitAction(action);
        }
    else
    {
    keyCode = 0;
    }
    }
     
    function imKeyDown() {
    // capture the key code incase of 'key up' or 'key down' arrow keys are used
    if (window.event.keyCode == keyDownCode || window.event.keyCode == keyUpCode)
            keyCode = window.event.keyCode;
         else
            keyCode = 0;
    }
     
    function imEnable(elementID) {
      element = document.getElementById(elementID);
      if (element != null) {
        element.disabled = false;
      }
    }
     
    function imDisable(elementID) {
      element = document.getElementById(elementID);
      if (element != null) {
        element.disabled = true;
      }
    }
     
    function imToggleDisabled(elementID) {
      element = document.getElementById(elementID);
      if (element != null) {
        element.disabled = ! element.disabled;
      }
    }
     
    function imExpandCollapsePageSection(elementID, hideSectionLabel, showSectionLabel, imageHidePath, imageShowPath) {
        element = document.getElementById(elementID + '_content');
        if (element == null) {
            return;
        }
        if (element.style.display == 'none') {
            element.style.display = '';
            imageElement = document.getElementById(elementID + '_image');
            if (imageElement != null) {
                imageElement.src = imageHidePath;
                imageElement.alt = hideSectionLabel;
                imageElement.title = hideSectionLabel;
            }
            
            displayElement = document.getElementById(elementID + '_display');
            if (displayElement != null) {
            displayElement.value = 'true';
            }
        } else {
     
            element.style.display = 'none';
            imageElement = document.getElementById(elementID + '_image');
            if (imageElement != null) {
                //imageElement.src = '/castylesr5.1/images/arrow_down.png';
                imageElement.src = imageShowPath;
                imageElement.alt = showSectionLabel;
                imageElement.title = showSectionLabel;
            }
            
            displayElement = document.getElementById(elementID + '_display');
            if (displayElement != null) {
            displayElement.value = 'false';
            }
        }
    }
     
    function imAddCheckAll(parentId, allId, checkboxName, title) {
      var enabledCnt = 0;
      var checkedCnt = 0;
      for (var i=0 ; i < document.forms.main.elements.length ; i++) {
        var e = document.forms.main.elements[i];
        if (e.name.match(checkboxName + '*')) {
          if (!e.disabled && !e.readonly) {
            enabledCnt++;
            if (e.checked) {
              checkedCnt++;
            }
          }
        }
      }
      if (enabledCnt > 1) {
        var eInput = document.createElement("input");
        eInput.type = 'checkbox';
        eInput.id = allId;
        eInput.className = 'im-checkall';
        if (title != null) {
        eInput.title = title;
        }
        eInput.onclick = function () { return imCheckAll(allId, checkboxName); };
        var parent = document.getElementById(parentId);
        parent.appendChild(eInput);
        if (checkedCnt == enabledCnt) {
          eInput.checked = true;
        }
      }
    }
     
    function imCheckAll(allId, checkboxName) {
      var allField = document.getElementById(allId);
      var val = allField.checked;
      for (var i=0 ; i < document.forms.main.elements.length ; i++) {
        var e = document.forms.main.elements[i];
        if (e.name.match(checkboxName + '*')) {
          if (!e.disabled && !e.readonly) {
            e.checked = val;        
            for (var j=0 ; j < e.attributes.length ; j ++) {
              var attr = e.attributes[j];
              if (attr.name.toLowerCase() == "onclick") {
                eval(attr.value);
              }
            }
          }
        }
      }
    }
     
    function imGenerateTag(tagid, data) {
      var tagField = document.getElementById(tagid);
      if (tagField.value == "") {
        tagField.value = data.replace(/[^A-Z0-9_]/gi, "");
      }
    }
     
    // clone a node (for copying node from one document to another on ie)
    function imCloneNode(fromelem, toelem) { 
      toelem.outerHTML = fromelem.outerHTML;
    }
     
    // converts any embedded html entities
    function imConvertEntities(data) {
      var matches = data.match(/&#\d+;?/g);
      if (matches) {
        for(var i = 0; i < matches.length; i++) {
          var replacement = String.fromCharCode((matches[i]).replace(/\D/g,""));
          data = data.replace(/&#\d+;?/,replacement);
        }
      }
      return data;
    }
     
     
    // Framework Servlets
    //-------------------
    // current environment alias
    var fwEnvAlias;
     
    // Parse current URL to set current environment alias
    function fwParsePathname() {
      var pathname = window.location.pathname;
      // current request context is set in app\page\global_head.jsp into fwRequestContext 
      pathname = pathname.substring(pathname.indexOf(fwRequestContext) + fwRequestContext.length)
      var parts = pathname.split('/');
      if (parts.length >= 2) {
        fwEnvAlias = parts[1];
      }
    }
     
     
    // Returns the current request context (/idm)
    function fwGetRequestContext() {
      return fwRequestContext;
    }
     
     
    // Returns the current environment alias
    function fwGetEnvAlias() {
      if (fwEnvAlias == null) {
        fwParsePathname()
      }
      return fwEnvAlias;
    }
     
     
    // Formats an associative array of parameter/value pairs into a POST data string
    function fwFormatPostData(params) {
      var postData = null;
      if (params != null) {
        for (var paramName in params) {
          var paramValue = params[paramName];
          if (typeof paramValue == 'boolean' ||
              typeof paramValue == 'number' ||
              typeof paramValue == 'string') {
            if (postData == null) {
              postData = '';
            }
            else {
              postData += '&';
            }
            postData += paramName;
            postData += '=';
            if (encodeURIComponent) {
                postData += encodeURIComponent(paramValue);
            } else {
                postData += escape(paramValue);
            }
          }
        }
      }
      return postData
    }
     
     
    // Formats an associative array of parameter/value pairs into a GET query string
    function fwFormatQueryString(params) {
      return fwFormatPostData(params);
    }
     
     
    // Returns URL for specified Framework Global Servlet.  If parameters are specified,
    // then they are included in the query string of the returned URL.
    // servletName: the name of the Framework Global Servlet
    // params: an associative array of parameter/value pairs to be included in the query string
    function fwGlobalServletURL(servletName, params) {
      var url = fwGetRequestContext() + '/' + servletName;
      if (params != null) {
        url += '?' + fwFormatQueryString(params);
      }
      return url;
    }
     
     
    // Returns URL for specified Framework Environment Servlet.  If parameters are specified,
    // then they are included in the query string of the returned URL.
    // servletName: the name of the Framework Environment Servlet
    // params: an associative array of parameter/value pairs to be included in the query string
    function fwEnvServletURL(servletName, params) {
      var url = fwGetRequestContext() + '/' + fwGetEnvAlias() + '/' + servletName;
      if (params != null) {
        url = url + '?' + fwFormatQueryString(params);
      }
      return url;
    }
     
     
    // Returns URL for specified Framework Session Servlet.  If parameters are specified,
    // then they are included in the query string of the returned URL.
    // servletName: the name of the Framework Session Servlet
    // params: an associative array of parameter/value pairs to be included in the query string
    function fwSessionServletURL(servletName, params) {
      return fwEnvServletURL(servletName, params);
    }
     
     
     
    // Framework AJAX
    //-----------------------
     
    // Cache of XMLHttpRequest objects
    var fwXmlHttpCache = new Object();
     
    // Returns a new XMLHttpRequest object, or false if this browser doesn't support it.
    // If a cache key is specified, the XMLHttpRequest may be cached and reused.
    // cacheKey: optional key for caching the created XMLHttpRequest object
    function fwRequestObject(cacheKey) {
      var xmlHttp = false;
      if (cacheKey != null) {
        xmlHttp = fwXmlHttpCache[cacheKey];
      }
      if (xmlHttp) {
        // return cached XMLHttpRequest;
        return xmlHttp;
      }
      if (window.XMLHttpRequest) {
        // create new xmlhttprequest in non-microsoft browsers
        xmlHttp = new XMLHttpRequest();
      }
      else if (window.ActiveXObject) {
        // create new xmlhttprequest via ms activex
        try {
          // try to create new xmlhttprequest in later versions of ie
          xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e1) {
          try {
            // try to create new xmlhttprequest in older versions of ie
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
          }
          catch (e2) {
          }
        }
      }
      if (cacheKey != null) {
        // cache XMLHttpRequest
        fwXmlHttpCache[cacheKey] = xmlHttp;;
      }
      return xmlHttp;
    }
     
     
    // Make a request to url with callback to JavaScript function
    // url: url of request (may include query string parameters)
    // postParams: associative array of POST parameters (request will be GET if there are no params)
    // fCallback: javascript function to call with one of the following parameters automatically added:
    //   responseText - if whenComplete is true, then this parameter will be passed with the response text from the request
    //   xmlHttp - if whenComplete is false, then this parameter will be passed with the XMLHttpRequestObject encapsulating the status of the request
    // callbackParams: optional associative array of callback function parameters (this associative array will automatically
    //   be added as a parameter when the callback function is called
    // whenComplete: if true (default), callback function will only be called when the request is complete and successful
    function fwRequest(url, postParams, fCallback, callbackParams, whenComplete) {
      var method = 'get'
      var header = null;
      var async = true;
      var postData = null;
      if (postParams != null) {
        method = 'post';
        header = 'Content-Type:application/x-www-form-urlencoded;charset=UTF-8';
        postData = fwFormatPostData(postParams);
      }
      if (fwRequest.arguments.length < 5) {
        whenComplete = true;
      }
     
      var xmlHttp = fwRequestObject();
      
      if (whenComplete) {
      xmlHttp.onreadystatechange = function() {
          if (xmlHttp.readyState == 4) {
            if (xmlHttp.status == 200) {
              fCallback(xmlHttp.responseText, callbackParams);
            }
          }
      };
      }
      else {
      xmlHttp.onreadystatechange = function() {
          fCallback(xmlHttp, callbackParams);
      }
      }
      
      xmlHttp.open(method, url, async);
      if (header != null) {
        xmlHttp.setRequestHeader(header.split(':')[0], header.split(':')[1]);
      }
      
      xmlHttp.send(postData);
      return xmlHttp;
    }
     
     
    // Make a request and set inner HTML with the response of the request.
    // elementID: id of the HTML element for which the innerHTML attribute will be set
    // url: url of request (may include query string parameters)
    // postParams: associative array of POST parameters (request will be GET if there are no params)
    function fwRequestAndSetInnerHTML(elementID, url, postParams) {
      var element = document.getElementById(elementID);
      var callbackParams = new Array();
      callbackParams["element"] = element;
      
      var fCallback = function(responseText, callbackParams) {
        var element = callbackParams["element"];
        if (element != null) {
          element.innerHTML = responseText;
        }
      };
      
      fwRequest(url, postParams, fCallback, callbackParams)
    }
     
     
    // Make a request and evaluate response as JavaScript.
    // url: url of request (may include query string parameters)
    // postParams: associative array of POST parameters (request will be GET if there are no params)
    function fwRequestAndEval(url, postParams) {
      var fCallback = function(responseText) {
        global.eval(responseText);
      };
      
      fwRequest(url, postParams, fCallback);
    }
     
     
    // Make a request to current Framework Page request handler with callback to JavaScript function.
    function fwPageRequest(postParams, fCallback, callbackParams, whenComplete) {
      var url = fwSessionServletURL('fwpagerequest');
      fwRequest(url, postParams, fCallback, callbackParams, whenComplete);
    }
     
     
    // Make a request to current Framework Page request handler and set inner HTML with the response of the request.
    function fwPageRequestAndSetInnerHTML(elementID, postParams) {
      var url = fwSessionServletURL('fwpagerequest');
      fwRequestAndSetInnerHTML(elementID, url, postParams);
    }
     
     
    // Make a request to current Framework Page request handler and evaluate response as JavaScript.
    function fwPageRequestAndEval(postParams) {
      var url = fwSessionServletURL('fwpagerequest');
      fwRequestAndEval(url, postParams);
    }
     
     
     
    // Framework Popup Menu
    //---------------------
     
    // onclick handler to hide popup menu
    if (document.documentElement) {
      document.documentElement.onclick = function(event) {
     
     
        var searchbutton = document.getElementsByName("Search")[0];
        if (searchbutton != null) {
    }
        var popmenu = document.getElementById("fw-popmenu");
        if (popmenu != null) {
          popmenu.style.visibility = "hidden";
      // on IE 6 we have to hide the iframe too (see the comment below where the iframe is created)
          if (imIs_ie6) {
            var popmenuiframe = document.getElementById("fw-popmenu-iframe");
        if (popmenuiframe != null) {
          popmenuiframe.style.visibility = "hidden";
        }
          }
        }
      }
    }
     
     
    // Display a popup menu of links.
    // eventX: X coordinate from a mouse event
    // eventY: Y coordinate from a mouse event
    // links: associative array of "name"/"link"
    // title: title for popup menu
    function fwPopMenu(eventX, eventY, links, title) {
      // get body element as container for popmenu
      var content = document.body;
      
      // check for and remove existing popmenu
      var popmenu = document.getElementById("fw-popmenu");
      if (popmenu != null) {
        content.removeChild(popmenu);
      }
      
      // create popmenu and add to container
      popmenu = document.createElement("div");
      popmenu.id ="fw-popmenu";
      
      // create popmenu title
      if (title != null) {
        popmenutitle = document.createElement("div");
        popmenutitle.id = "fw-popmenu-title";
        popmenutitle.className = "fw-popmenu-title";
        popmenutitle.appendChild( document.createTextNode(title) );
        popmenu.appendChild(popmenutitle);
      }
      
      // create popmenu list of menu items
      popmenuul = document.createElement("ul");
      for (var i=0 ; i<links.length ; i++) {
        var menuli = document.createElement("li");
        if (links[i]["link"] != null && links[i]["link"].length > 0) {
      var menulink = document.createElement("a");
          menulink.href = links[i]["link"];
          var taskname = document.createTextNode(links[i]["name"]);
          menulink.appendChild(taskname);
          menuli.appendChild(menulink);
        }
        else {
          var taskname = document.createTextNode(links[i]["name"]);
          menuli.appendChild(taskname);
        }
        popmenuul.appendChild(menuli);
      }
      popmenu.style.visibility = "hidden";
      popmenu.appendChild(popmenuul);
      content.appendChild(popmenu);
     
      // set css class for popmenu 
      popmenu.className = "fw-popmenu";
      
      // position popup menu at mouse click
      // X
      var scrollX = imGetScrollX();
      var clientWidth = imGetClientWidth();
      var x = eventX + scrollX;
      if (x + popmenu.clientWidth > clientWidth + scrollX) {
        x = x - ( (x + popmenu.clientWidth) - (clientWidth + scrollX) );
      }
      popmenu.style.left = x + 'px';
      // Y
      var scrollY = imGetScrollY();
      var clientHeight = imGetClientHeight();
      var y = eventY + scrollY;
      if (y + popmenu.clientHeight > clientHeight + scrollY) {
        y = y - ( (y + popmenu.clientHeight) - (clientHeight + scrollY) );
      }
      popmenu.style.top = y + 'px';
      popmenu.style.zIndex = "10";
      
      // on IE 6 select boxes will show through DHTML layers (z-index doesn't help)
      // only solution is to hide the entire select or use a dynamically created and positioned 
      // iframe to cover the select.  when sized and positioned behind the popup this provides
      // the behavior that you would expect.
      if (imIs_ie6) {
        var popmenuiframe = document.getElementById("fw-popmenu-iframe");
        if (popmenuiframe != null) {
          content.removeChild(popmenuiframe);
        }
        var popmenuiframe = document.createElement("iframe");
        popmenuiframe.style.position = 'absolute';
        popmenuiframe.id = "fw-popmenu-iframe";
        popmenuiframe.src = 'javascript:false;';
        popmenuiframe.style.visibility = "hidden";
        popmenuiframe.style.left = popmenu.style.left;
        popmenuiframe.style.top = popmenu.style.top;
        popmenuiframe.style.height = popmenu.offsetHeight;
        popmenuiframe.style.width = popmenu.offsetWidth;
        popmenuiframe.frameborder = "0";
        popmenuiframe.scrolling = 'no';
        popmenuiframe.style.zIndex = "9";
        
        content.appendChild(popmenuiframe);
        popmenuiframe.style.visibility = "visible";
      }
      
      // show popmenu
      popmenu.style.visibility = "visible";
    }
     
     
    //Event handler to show a popup task menu of tasks that current administrator can perform on specified object.
    //container: element id of container for task menu button
    //nestTask: true to have task menu items trigger nested tasks (IMMEDIATE nested tasks only)
    //objectType: the object type of the object for which we want the tasks
    //uniqueName: the unique name of the object for which we want the tasks
    //tasksToShow: All, NoHidden, Include, Exclude
    //All: all tasks which administrator can perform on specified object
    //NoHidden: all tasks which administrator can perform on specified object except those which are flagged as hidden
    //Include: only those tasks in the taskTags list that the current administrator can perform on the specified object
    //Exclude: all tasks which administrator can perform on specified object except those tasks in the taskTags list
    //taskTags: comma separated list of task tags to Include or Exclude
    //buttonName: localized button name
    function fwTaskMenu(container, nestTask, objectType, uniqueName, tasksToShow, taskTags, buttonName, toolTip) {
      Ext.onReady(function() {
        var btnHandler = function(btn) {
          btn.el.frame();
        }
        // CQ 164751 - need to initialize QuickTips before use
        Ext.QuickTips.init();
     
        var menuItems = [];
        if (buttonName == null) {
        buttonName = 'Actions';
        }
     
     
        if (toolTip == null) {
        toolTip = buttonName;
        }
        var b = new Ext.Button({
          renderTo : container,
          text     : buttonName,
          handler  : btnHandler,
          menu: menuItems,
      tooltip  : toolTip,
      tooltipType: 'title',
          showMenu : function(){
            if (this.rendered && this.menu) {
              var btn = this;
              btn.disabled = true;
              if (this.tooltip) {
                Ext.QuickTips.getQuickTip().cancelShow(this.btnEl);
              }
              if (this.menu.isVisible()) {
                this.menu.hide();
              }
     
              if (btn.menu.items.getCount() == 0) {
     
                // make ajax request to tasks servlet
                var servletParams = {
                  "nestTask": nestTask,
                  "objectType": objectType,
                  "uniqueName": uniqueName,
                  "tasksToShow": tasksToShow,
                  "taskTags": taskTags
                }
     
                var fwtasks = fwSessionServletURL('fwtasks');
     
                btn.el.frame(null, 4);
     
                Ext.Ajax.request({
                  url: fwtasks,
                  params: servletParams,
                  success: function(response, opts) {
                    var res = response.responseText;
                    var result = Ext.util.JSON.decode(res);
                    for (i = 0; i < result.tasks.length; i++) {
                      btn.menu.addItem({
                        text    : result.tasks[i].name,
                        href : result.tasks[i].link
                      });
                    }
     
                    btn.menu.ownerCt = btn;
                    btn.menu.show(btn.el, btn.menuAlign);
                    btn.el.stopFx() ;
                    btn.disabled = false;
                  },
                  failure: function(response, opts) {
                    Ext.Msg.alert('Error', 'Unable to determine actions for this object.');
                    btn.el.stopFx() ;
                    btn.disabled = false;
                    //console.log('server-side failure with status code ' + response.status);
                  },
                  timeout: 120000
                });
              }
              else {
                btn.menu.ownerCt = btn;
                btn.menu.show(btn.el, btn.menuAlign);
                btn.disabled = false;
              }
            }
            return this;
          },
          listeners: {
          menuhide: function(){
          this.focus();
          }
          }
        });    
      });
    }
     
     
    imAddEvent(window, "load", imOnLoad);
      popmenuiframe.style.width = popmenu.offsetWidth;
        popmenuiframe.frameborder = "0";
        popmenuiframe.scrolling = 'no';
        popmenuiframe.style.zIndex = "9";
        
        content.appendChild(popmenuiframe);
        popmenuiframe.style.visibility = "visible";
      }
      
      // show popmenu
      popmenu.style.visibility = "visible";
    }
     
     
    //Event handler to show a popup task menu of tasks that current administrator can perform on specified object.
    //container: element id of container for task menu button
    //nestTask: true to have task menu items trigger nested tasks (IMMEDIATE nested tasks only)
    //objectType: the object type of the object for which we want the tasks
    //uniqueName: the unique name of the object for which we want the tasks
    //tasksToShow: All, NoHidden, Include, Exclude
    //All: all tasks which administrator can perform on specified object
    //NoHidden: all tasks which administrator can perform on specified object except those which are flagged as hidden
    //Include: only those tasks in the taskTags list that the current administrator can perform on the specified object
    //Exclude: all tasks which administrator can perform on specified object except those tasks in the taskTags list
    //taskTags: comma separated list of task tags to Include or Exclude
    //buttonName: localized button name
    function fwTaskMenu(container, nestTask, objectType, uniqueName, tasksToShow, taskTags, buttonName, toolTip) {
      Ext.onReady(function() {
        var btnHandler = function(btn) {
          btn.el.frame();
        }
        // CQ 164751 - need to initialize QuickTips before use
        Ext.QuickTips.init();
     
        var menuItems = [];
        if (buttonName == null) {
        buttonName = 'Actions';
        }
     
     
        if (toolTip == null) {
        toolTip = buttonName;
        }
        var b = new Ext.Button({
          renderTo : container,
          text     : buttonName,
          handler  : btnHandler,
          menu: menuItems,
      tooltip  : toolTip,
      tooltipType: 'title',
          showMenu : function(){
            if (this.rendered && this.menu) {
              var btn = this;
              btn.disabled = true;
              if (this.tooltip) {
                Ext.QuickTips.getQuickTip().cancelShow(this.btnEl);
              }
              if (this.menu.isVisible()) {
                this.menu.hide();
              }
     
              if (btn.menu.items.getCount() == 0) {
     
                // make ajax request to tasks servlet
                var servletParams = {
                  "nestTask": nestTask,
                  "objectType": objectType,
                  "uniqueName": uniqueName,
                  "tasksToShow": tasksToShow,
                  "taskTags": taskTags
                }
     
                var fwtasks = fwSessionServletURL('fwtasks');
     
                btn.el.frame(null, 4);
     
                Ext.Ajax.request({
                  url: fwtasks,
                  params: servletParams,
                  success: function(response, opts) {
                    var res = response.responseText;
                    var result = Ext.util.JSON.decode(res);
                    for (i = 0; i < result.tasks.length; i++) {
                      btn.menu.addItem({
                        text    : result.tasks[i].name,
                        href : result.tasks[i].link
                      });
                    }
     
                    btn.menu.ownerCt = btn;
                    btn.menu.show(btn.el, btn.menuAlign);
                    btn.el.stopFx() ;
                    btn.disabled = false;
                  },
                  failure: function(response, opts) {
                    Ext.Msg.alert('Error', 'Unable to determine actions for this object.');
                    btn.el.stopFx() ;
                    btn.disabled = false;
                    //console.log('server-side failure with status code ' + response.status);
                  },
                  timeout: 120000
                });
              }
              else {
                btn.menu.ownerCt = btn;
                btn.menu.show(btn.el, btn.menuAlign);
                btn.disabled = false;
              }
            }
            return this;
          },
          listeners: {
          menuhide: function(){
          this.focus();
          }
          }
        });    
      });
    }
     
     
    imAddEvent(window, "load", imOnLoad);

    Attachment(s)

    js
    task.js   26 KB 1 version