Bug #565
closedHow to use WObject::implementStateless(...)
0%
Description
Please Provide full working examples on Usage of these methods
WObject::implementStateless(..)
WObject::resetLearnedSlot()
WObject::implementJavaScript()
And how to use
WStatelessSlot
Updated by Koen Deforche about 14 years ago
- Status changed from New to Resolved
Hey Omair,
This is complicated. The first thing to realize is when to use it: if you want to write JavaScript without writing JavaScript, i.e. if you want C to be automagically converted to JavaScript.
There is a tutorial dedicated to this: http://www.webtoolkit.eu/wt/doc/reference/html/example.html, which is included as the "tree" example in Wt.
There is now also a more convenient overload available of EventSignal::connect(const std::string&)
which takes as argument a JavaScript function:
e.g.
clicked().connect("function() { alert('hello!'); }");
This is a more convenient alternative than JSlot
when you do not need the automatic disconnect when the "receiver" goes out of scope. You shouldn't use WStatelessSlot
API directly (it's not public API, although a pointer to it is referenced from WObject methods).
Note that stateless slot implementations are a mere optimisation to eliminate a server round trip for simple javascript updates. You are using them already since for example WWidget::show() is implemented in this way: if you connect WWidget::show() to e.g. a clicked() signal, then this is optimized in client-side JavaScript code.
Regards,
koen