Project

General

Profile

WTemplate can cause script-exception

Added by Ulf Johnsson about 5 years ago

Hi!

Not to long ago you guys fixed "Using properties directly on the element instead of jQuery.data" issues. See commit to Wt3-branch "c2e1edc09e180cacb90c2e037e4f367a460ad4cf" made about a month ago

I think this issue is still present in the WTemplate class. It is hard to reproduce and I cannot create a small example that illustrates this.

The issue I run into is that a wt-script tries to resolve a node based on its ID, but the node no longer exists, which results in a exception.

In my code I have exchanged the WTemplate widget to a WContainerWidget that does the same thing, which works fine. Since I used to have the same issue with WContainerWidget I suspect that the WTemplate-class has been overlooked.

Is it possible that this widget was overlooked during the patching? If so, can you push a patch for that widget (perhaps there are more?)

BR, Ulf.


Replies (2)

RE: WTemplate can cause script-exception - Added by Roel Standaert about 5 years ago

There must be some other issue, because WTemplate never used jQuery.data.

RE: WTemplate can cause script-exception - Added by Ulf Johnsson about 5 years ago

Very possible.

The output from the exception I am seeing looks like this (the first part of it anyway, it is very long):

[error] "WApplication: JavaScript error: {""exception_description"":""Unable to set property 'className' of undefined or null reference"",""exception_js"":""Wt._p_.response(-76987545);{var j505=Wt3_3_12.$('ogs1nt5');
var j506=document.createElement('div');j505.parentNode.replaceChild(j506,j505);
j506.setAttribute('id', 'ogs1nt5');

j506.className='Wt-popup';
j506.style.position='absolute';
j506.style.zIndex='100';
j506.style.width='100.0%';
j506.style.height='100.0%';
j506.style.left='0.0px';
j506.style.right='0.0px';
j506.style.top='0.0px';
j506.style.bottom='0.0px';
j506.style.backgroundImage='url(...

And I defined my WTemplate like this:

...
const char *templateText = "<div style=\"height:100.0%; width:100.0%; "
               "background-image:url('data:image/png;base64,iVBORw0');"
               "background-repeat:repeat;background-position: top left;\"/>";

m_widget = new Wt::WTemplate(templateText, view);
m_widget->setPopup(true);
m_widget->setPositionScheme(Wt::Absolute);
m_widget->setOffsets(0);

I know based on the output that it is the WTemplate object that has somehow become undefined (I recognize the picture data).

The output seems very simmilar to the issue we were previously experiencing with other widgets (like WContainerWidget).

Any ideas?

BR, Ulf.

    (1-2/2)