using of javascript

hi all !

Can I use a javascript library e.g. for xmpp communications ( strophe.js ) with xojo ? I tried to put some script functions in a pagesource but
I only get the “html” parts displayed on the page but no javascript things. I tried it with alert … . If I put the html-script as test.html on a web page it worked.

are there any documentations or samples how to use javascript, library and callbacks ? ( with exception “executeJavaScript” ? )

thank you in advance for any help !

I was also looking for some examples of Xojo/Javascript I couldn’t really find anything either.

Have you guys read the WebControlSDK document in the …/Extras/WebSDK folder?

It has got some nice examples on how to build custom web controls, and on page 20 there is a short description about the “Xojo.loadScript” function that can be used to dynamically load JavaScript scripts into your applciation.

thank you I will go into it !

hi ! I try the sample on page but I fail:

new webproject
new class
super webcontrolwrapper
–> cannot change name from class1 to … it always switch back to class1 ! so I worked with class1
2) Several problems a the computed property and warnings on the javascriptnamespace

ControlAvailableInBrowser() does not exists
me.* does not mean anything with this method
javascriptnamespace is alrady defined

I’am on MAC 10.8.3. Did this sample works for anybody ?

Thanks,
Harald

um… when you got that error “cannot change name from class1 to …” were you maybe trying to change the NAME to WebControlWrapper?

I don’t get an error, if i save the project he switches back to class1. And it is not always, after playing with save edit change value of super and back, but I found not a clear way to workaround …
it sometimes works :frowning:

Could you attach a screenshot of what you’re trying to do?

Make sure you are pressing ENTER or TAB after entering the name. it could be that it’s not saving the change to the project.

You cannot upload a local file. Upload it somewhere on the web and link to it. There are plenty of file hosting services. Better still, attach them to a Feedback report so Xojo will be sure to see it.

thanks !

Shared Properties and Methods don’t have an Instance connected to them. Without that ControlAvailableInBrowser (and the following Me statement) have no meaning.

Ok, Thank’s, I only try to follow the First Sample in the webSDK document. I should convert the html in a Computed property and Paste this Code in the setter . So i tried to get this Running

is a sample available for

WebControlWrapper.LoadLibraries ( Callback as String, Paramarray URLs as String )

If I type my webcontrolwrapper controls name in the ide I don’t get the proposal for a method “LoadLibraries”.

That’s strange, I certainly do. Remember though, you can only call LoadLibraries from within the control or one of its subclasses. It will not work from an instance that has been placed on a WebPage.

thank you for the hint. It can call it from the control:

WebControlWrapper.LoadLibraries(“onStrophe”,“http://glyps.on-rev.com/strophe.js”)

I have found that I can also load a library from the app.htmlheader. but where is the difference and
how can I get the callbacks ? In the library I get a callback from “onConnect” but I have no idea how I could
get them in an Xojo webapplication.

thank you for your help !

The callback happens on the client side. if you want the event to come back to the server, you’d need to do that yourself.

The big difference between this and App.HTMLHeader is that if you were wrapping this control for resale, you wouldn’t want to need to say to the customer “…and you’ll have to copy this code into App.HTMLHeader for it to work.”

thank you for the explanation. I am able to connect to server and get the callbacks (tested only via alert).

The “last step” :slight_smile: for getting it technical running would now be that instead of “alert” I can put the information into a xojo control on my
webpage … maybe I can do it like in the olark examples with a triggerServerEvent in the javascript function.

thank you for the explanation. I am able to connect to server and get the callbacks (tested only via alert).

The “last step” :slight_smile: for getting it technical running would now be that instead of “alert” I can put the information into a xojo control on my
webpage … maybe I can do it like in the olark examples with a triggerServerEvent in the javascript function.

Absolutely. triggerServerEvent is the way to go.

thanks, via app.htmlheader the things are working but I don’t get it to run it with WebControlWrapper.LoadLibraries. I tried for example:
WebControlWrapper.LoadLibraries(“onConnect”,“http://glyps.on-rev.com/strophe.js”)
and get:
Could not execute returned javascript: Can’t find variable: Strophe --> “so it is not loaded because this is part of the lib”
ReferenceError: Can’t find variable: onConnect --> “this I see only in the errorconsole of safari”

Is there a example for WebControlWrapper.LoadLibraries available ?

thank you in advance !