Skip to main content

Cannot load the same mashup again based on conditions

Suggest edit
Updated on November 15, 2021

Learn more about the possible issues and their resolution to ensure that you can load the same mashup again based on certain conditions.

Condition

The mashup does not load when you load the same mashup again based on certain conditions.

Cause

When the postMessage handler registration on the host fails, you cannot load the same mashup again based on certain conditions. The postMessage handler registration must be successful to allow resizing and communication between the host page and gadget.

Solution

  1. Put a debugger in the HostActionProcessor or GadgetActionProcessor . If the debugger does not stop, then invoke pega.Mashup.Communicator.register (pega.Mashup.hostActionsProcessor) and _initAllPegaObjects() when the mashup script is loaded for the first time.

  2. For subsequent new mashup <div> snippets that you add, invoke _initAllPegaObjects().

    For example: See the following code sample:
    pega.Mashup.hostActionsProcessor = function(notifiedData){
    
      var gadgetIfrName = notifiedData.src,
    
          actionInfo = notifiedData.payload,gadgetId,gadget;
    
      gadgetId = gadgetIfrName;
    
      if(gadgetIfrName && gadgetIfrName.match(/Ifr$/)){
    
        gadgetId = gadgetIfrName.substring(0, gadgetIfrName.length-3);
    
      }                
    
      gadget = pega.web.mgr._getGadgetByID(gadgetId);
    
      if(!gadget){
    
        return;
    
      }
    
      switch(actionInfo.name) {
    
        case "loaded":
    
          if(pega.web.isWebMashup && gadget._oFrame) {
    
          
    
            //resetting height for initial mashup load , removing skeleton height
    
            if(gadget._bMaxIframeSize && gadget._oFrame.style.height == "400px"){
    
              gadget._oFrame.style.height = "";
    
            }
    
            //console.info("hostActionsProcessor: loaded");
    
            pega.Mashup.Communicator.send({name: "registerResize"}, {
    
              target: gadgetIfrName
    
            });
    
          }
    
          //console.info("hostActionsProcessor: registerResize");
    
          gadget._oDiv.pyStreamName = actionInfo.pyStreamName;
    
          break;
    
        case "resizeMashup":
    
          var height = actionInfo.height;
    
    
    <script>
                
    
    function loadMashup() {
    
         var snippetDiv = document.createElement("div");
    
         snippetDiv.setAttribute("data-pega-gadgetname", "PegaGadget");
    
         snippetDiv.setAttribute("data-pega-action", "createNewWork");
    
         snippetDiv.setAttribute("data-pega-action-param-classname", "OES023-Myapplication-Work-Interaction");
    
         snippetDiv.setAttribute("data-pega-action-param-flowname", "pyStartCase");
    
         snippetDiv.setAttribute("data-pega-isdeferloaded", "false");
    
         snippetDiv.setAttribute("data-pega-threadname", "MashupThread");
    
         snippetDiv.setAttribute("data-pega-applicationname", "Myapplication");
    
         snippetDiv.setAttribute("data-pega-resizetype", "stretch");
    
         snippetDiv.setAttribute("data-pega-url", "http://sample.pega.com/prweb");
    
         snippetDiv.setAttribute("data-pega-action-param-parameters", JSON.stringify({
    
             "UserIndentifier": "cherj",
    
             "Password": "xyzdkjmv"
    
         }) + "");
    
    
         document.getElementById("wrapperDiv").appendChild(snippetDiv);
    
         if (pega && pega.Mashup) {
    
             //if mashup script already loaded
    
             _initAllPegaObject();
    
         } else {
    
             // load mashup scripts on-demand
    
             var mashupScriptElement = document.createElement("script");
    
             mashupScriptElement.onload = function () {
    
                 // 1. register post message communicator
    
                 pega.Mashup.Communicator.register(pega.Mashup.hostActionsProcessor);
    
                 // 2. trigger mashup loading explicitly for asyn case
    
                 _initAllPegaObjects();
    
    
             };
    
             mashupScriptElement.src = "http://samples.pega.com/prweb?pyActivity=pzIncludeMashupScripts";
    
             document.head.appendChild(mashupScriptElement);
    
         }
    
     } 
    
    </script
    
    <div id="wrapperDiv"></div>
    
    <button onclick="loadMashup">Load Mashup</button>
  • Previous topic Troubleshooting issues with loading mashups
  • Next topic Cannot load a mashup asynchronously based on an event or a flag
Did you find this content helpful? YesNo

0% found this useful

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us