Cannot load the same mashup again based on conditions
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
- Put a debugger in the
HostActionProcessor
orGadgetActionProcessor
. If the debugger does not stop, then invokepega.Mashup.Communicator.register (pega.Mashup.hostActionsProcessor)
and_initAllPegaObjects()
when the mashup script is loaded for the first time. - 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 Cannot load mashup due to SECU0019 exception Next topic Cannot load a mashup asynchronously based on an event or a flag