Project

General

Profile

javascript crash when integrating a "widgetset" from another wt server

Added by Anonymous almost 4 years ago

When i try to integrate a simple widget from a wt server (with widgetset entrypoint) in a website(wt server)

@Konstantin Malanin std::string *div = env.getParameter("div");

std::string defaultDiv = "div";

if (!div)

div = &defaultDiv;

auto app = cpp14::make_unique(env);

if (div) {

app->setJavaScriptClass(*div);

std::unique_ptrWt::Dbo::SqlConnectionPool UserDb = Session::createConnectionPool(app->appRoot() + "db/user.db");

std::unique_ptr uploadWidget = Wt::cpp14::make_unique(*UserDb); //same error with juste a wcontainerwidget

UploadWidget *uploadWidgetRaw = uploadWidget.get();

app->bindWidget(std::move(uploadWidget), *div);

std::string chat = app->javaScriptClass();

// + "document.body.appendChild(" + oAuthWidget->jsRef() + ");");

}

else {

std::cerr << "Missing: parameter: 'div'" << std::endl;

app->quit();

}

return app;@

on the main server that uses this widget :

auto container = this->addWidget(std::make_unique<WContainerWidget>());
container->setId("container");
container->doJavaScript("loadScript('//www.exemple.com/upload.js?div=" + container->id() + "', null);");

h1. WApplication: JavaScript error: {""exception_description"":""Cannot read property 'display' of undefined"",""exception_js"":""Wt._p_.response(2333980317);Wt4_3_0.WPopupMenu = function(v,c,w){function j(){k(c,null);c.style.display=\""none\"";setTimeout(function(){v.emit(c.id,\""cancel\"")},0)}function x(a,b){$(a).toggleClass(\""active\"",b)}function l(a){if(a.subMenu)return a.subMenu;else{var b=a.lastChild;if(b&&d.hasTag(b,\""UL\"")){a.subMenu=b;b.parentItem=a;$(b).mousemove(y);m(b);return b}else return null}}function F(a){a.style.display=\""block\"";if(a.parentNode==a.parentItem){a.parentNode.removeChild(a);c.parentNode.appendChild(a)}var b= d.px(a,\""paddingTop\"")+d.px(a,\""borderTopWidth\"");d.positionAtWidget(a.id,a.parentItem.id,d.Horizontal,-b);k(a,null);if(d.isIOS){$(a).unbind(\""touchstart\"",n).bind(\""touchstart\"",n);$(a).unbind(\""touchend\"",o).bind(\""touchend\"",o)}}function k(a,b){function z(h,e){if(h==e)return true;else if(e)return(e=e.parentNode.parentItem)?z(h,e):false;else return false}function p(h){var e,A;e=0;for(A=h.childNodes.length;e<A;++e){var f=h.childNodes[e];if(z(f,b)){if(f!==b)(f=l(f))&&p(f)}else{x(f,false);if(f=l(f)){f.style.display= \""none\"";p(f)}}}}p(a)}function y(a){for(a=d.target(a);a&&!d.hasTag(a,\""LI\"")&&!d.hasTag(a,\""UL\"");)a=a.parentNode;if(d.hasTag(a,\""LI\""))if(a!==q){q=a;x(a,true);var b=l(a);b&&F(b);k(c,a)}}function G(){r=false;clearTimeout(g);if(w>=0)g=setTimeout(j,w)}function H(){r=true;clearTimeout(g)}function m(a){$(a).mouseleave(G).mouseenter(H)}function s(){return document.getElementById(c.id)!=null}function B(a){t=true;s()&&d.button(a)!=1&&j()}function u(){if(s()){t=false;j()}}function C(a){s()&&a.keyCode==27&&j()}function I(){if(d.isIOS){$(document).bind(\""touchstart\"", D);$(document).bind(\""touchend\"",E)}else $(document).bind(\""click\"",u)}function J(){if(d.isIOS){$(document).unbind(\""touchstart\"",D);$(document).unbind(\""touchend\"",E)}else $(document).unbind(\""click\"",u)}function D(a){a=a.originalEvent.touches;i=a.length>1?null:{x:a[0].screenX,y:a[0].screenY}}function n(a){a.stopPropagation()}function E(a){if(i){var b=a.originalEvent.changedTouches[0];Math.abs(i.x-b.screenX)<20&&Math.abs(i.y-b.screenY)<20&&u(a);i=null}}function o(a){a.stopPropagation()}c.wtObj=this;var d= v.WT,g=null,r=false,q=null,i=null,t=false;if(d.isIOS){$(c).bind(\""touchstart\"",n);$(c).bind(\""touchend\"",o)}this.setHidden=function(a){a||(t=false);if(g){clearTimeout(g);g=null}r=false;q=null;if(a){c.style.position=\""\"";c.style.display=\""\"";c.style.left=\""\"";c.style.top=\""\"";$(document).unbind(\""mousedown\"",B);J();$(document).unbind(\""keydown\"",C)}else{setTimeout(function(){$(document).bind(\""mousedown\"",B);I();$(document).bind(\""keydown\"",C)},0);c.style.display=\""block\""}k(c,null)};this.popupAt=function(a){m(a)};setTimeout(function(){m(c)}, 0);$(c).mousemove(y)}\n{var j264=Wt4_3_0.$('oj3egy8');\nj264.className='dropdown open';\n$('#oj3egy7').addClass('active');\nvar j265=Wt4_3_0.$('oj3egym');\nj265.style.display='';\nnew Wt4_3_0.WPopupMenu(Wt,Wt4_3_0.$('oj3egym'),-1);\nWt4_3_0.$('oj3egym').wtObj.setHidden(0);\nWt4_3_0.$('oj3egym').wtObj.popupAt(Wt4_3_0.$('oj3egy7'));\nWt4_3_0.positionAtWidget('oj3egym','oj3egy7',Wt4_3_0.Vertical);\n\n}Wt._p_.wsRqsDone(0);"",""stack"":""TypeError: Cannot read property 'display' of undefined\n    at Object.window.Wt4_3_0.css (https://exemple.com/root?wtd=ipQ1RekEloJG4fG2&sid=2333980313&webGL=true&scrW=2560&scrH=1440&tz=120&tzS=Europe%2FParis&htmlHistory=true&deployPath=%2Froot&request=script&rand=1035905051:1234:14)\n    at Object.window.Wt4_3_0.positionAtWidget (https://exemple.com/root?wtd=ipQ1RekEloJG4fG2&sid=2333980313&webGL=true&scrW=2560&scrH=1440&tz=120&tzS=Europe%2FParis&htmlHistory=true&deployPath=%2Froot&request=script&rand=1035905051:1921:12)\n    at eval (eval at doJavaScript (https://exemple.com/root?wtd=ipQ1RekEloJG4fG2&sid=2333980313&webGL=true&scrW=2560&scrH=1440&tz=120&tzS=Europe%2FParis&htmlHistory=true&deployPath=%2Froot&request=script&rand=1035905051:3235:14), <anonymous>:10:9)\n    at eval (eval at doJavaScript (https://exemple.com/root?wtd=ipQ1RekEloJG4fG2&sid=2333980313&webGL=true&scrW=2560&scrH=1440&tz=120&tzS=Europe%2FParis&htmlHistory=true&deployPath=%2Froot&request=script&rand=1035905051:3235:14), <anonymous>:12:24)\n    at eval (<anonymous>)\n    at doJavaScript (https://exemple.com/root?wtd=ipQ1RekEloJG4fG2&sid=2333980313&webGL=true&scrW=2560&scrH=1440&tz=120&tzS=Europe%2FParis&htmlHistory=true&deployPath=%2Froot&request=script&rand=1035905051:3235:14)\n    at handleResponse (https://exemple.com/root?wtd=ipQ1RekEloJG4fG2&sid=2333980313&webGL=true&scrW=2560&scrH=1440&tz=120&tzS=Europe%2FParis&htmlHistory=true&deployPath=%2Froot&request=script&rand=1035905051:3266:7)\n    at WebSocket.ws.onmessage (https://exemple.com/root?wtd=ipQ1RekEloJG4fG2&sid=2333980313&webGL=true&scrW=2560&scrH=1440&tz=120&tzS=Europe%2FParis&htmlHistory=true&deployPath=%2Froot&request=script&rand=1035905051:3500:15)""}"

Thank you for your help !


Replies (3)

RE: javascript crash when integrating a "widgetset" from another wt server - Added by Anonymous almost 4 years ago

Last point : the bug happens when i click on widget like menu or Wtableview not on load (the external widget is operational)

RE: javascript crash when integrating a "widgetset" from another wt server - Added by Anonymous almost 4 years ago

Up

need some help, i'm stuck with this problem

The crash occurs when click on WPopupMenu of the WNavigationBar or when i trigger the WSuggestionPopupor (wt version tested 4.1.2 and 4.3.1 under visual studio 2017)

RE: javascript crash when integrating a "widgetset" from another wt server - Added by Prasad Dixit over 3 years ago

I am also experiencing similar crash with following error: JavaScript error: {""exception_description"":""Cannot read property 'display' of undefined"

    (1-3/3)