WebSDK, triggerServerEvent results in EventLoop

Hey,

ich just played with web2.0 WebSDK to get my Controls to the next level :wink:
When using triggerServerEvent, Xojo stopps debugging and gives me an “EventLoop”.
It seems like this event doesn’t even get through to the “ExecuteEvent”.
The only Code there is:

// This event will fire if you call "this.triggerServerEvent" in your javascript code
// Return True to indicate that your code handled the event

System.DebugLog(name + " - " + parameters.ToString)

return true

And I have a Breakpoint on “System.DebugLog”, but that Event does never fire.

In the Browsers-JavascriptConsole I get an Error 404:

http://127.0.0.1:8080/B2734C627DB79CDF335BE14A32CBDECC7B5E1C1693B0B70CE21E83293060A7D1/comm/event/TgsRZw.headlineChanged

TgsRZw is the correct ControlID, headlineChanged is my EventName.
Browser-Side I’m calling it with:

that.triggerServerEvent("headlineChanged", "{data: " + encodeURIComponent(ed.bodyElement.innerHTML) + "}", true)

Is there anything I am missing?

Marius

Ok,

I found, that I have to use XojoWeb.JSONItem instead of just using “{}”. But this results in an internal Event-Loop inside the IDE??? :face_with_raised_eyebrow:

Are you still returning true in ExecuteEvent ?

Yes, of course. But it is not important, what you return if the Events doesn’t fire :wink:

Ohh, just because this isn’t obscure enough for an saturday evening in the office…

When you put some urlencoded text in the Javascript

var data = "test     test   test";
var js = new XojoWeb.JSONItem;
js.set("data", encodeURIComponent(data));
this.triggerServerEvent("headlineChanged", js, true);

Then in Xojo->ExecuteEvent:

System.DebugLog(parameters.ToString)

I get:

{“data”:“test%26nbsp%3B+%26nbsp%3B+%26nbsp%3Btest%26nbsp%3B+%26nbsp%3Btest”}

So my second project I worked at after coming from 2019r3 to an actual release and is the second time, Xojo magically changes some data.

From

test     test   test

to

test + + test + test

just without doing anything

Is that 2021r3.1 or Web2 actually released beta software? Or is just nobody working wit Xojo?
Or is there any reason why Xojo internally changes “%20” to “+”. Or asked differently: Is there any reason why - in the last time - I put data into variables and get other values back? Is this a new way of programming I missed?

See my post regarding WebPopup. In the example, it forces the pop-up selection changed event to fire when the index is changed programmatically (selection changed event currently broken otherwise in 2021r3.1). There’s a demonstration how to use the JsonItem object with JavaScript. JsonItems handle string encoding, so you should not be having to encode anything with URLEncode. A JSON object in JavaScript can natively read any (properly formatted - handled by JSONItem class in Xojo) JSON string as any other string.

Ok, but wht if my String is %20%20%20 because I really like %20 and I want to use it within my Control. and let’s say it is just %20 no encoding. Because %20 is my personal word for “i love you”.
So my wife gets a message with + (my personal code for “I hate you”). Perhaps we can agree, this is not the best way to deal with mit data.