Wt
3.3.8
|
A handle to a JavaScript representation of an object. More...
#include <Wt/WJavaScriptHandle>
Public Member Functions | |
WJavaScriptHandle () | |
Create an invalid WJavaScriptHandle. More... | |
WJavaScriptHandle (const WJavaScriptHandle &handle) | |
Copy constructor. | |
WJavaScriptHandle & | operator= (const WJavaScriptHandle &handle) |
Copy assignment operator. | |
bool | isValid () const |
Returns whether this is a valid handle. More... | |
std::string | jsRef () const |
Returns the JavaScript representation of the object. More... | |
void | setValue (const T &v) |
Set the value for this handle. More... | |
const T & | value () const |
Get the value for this handle. More... | |
A handle to a JavaScript representation of an object.
A WJavaScriptHandle allows to access and modify an object in JavaScript. This is useful to avoid server roundtrips when frequently updating something, e.g. to interact with and animate a WPaintedWidget.
You can use the value() of a WJavaScriptHandle just as you would normally, with the exception that it will be JavaScript bound, and so will any copies you make of it. You should not modify a JavaScript bound object, as this will not change its client side representation. Use the handle's setValue() method instead.
You can access (and modify) the value of a handle on the client side using jsRef().
You can update the value from the server with setValue(). Changes on the client side will be synced back to the server.
Currently, only WPaintedWidget allows the use of JavaScript exposable objects.
Wt::WJavaScriptHandle< T >::WJavaScriptHandle | ( | ) |
Create an invalid WJavaScriptHandle.
The handle will be invalid until a valid WJavaScriptHandle is copy-assigned to it.
bool Wt::WJavaScriptHandle< T >::isValid | ( | ) | const |
Returns whether this is a valid handle.
A handle is not valid if it is not connected to a JavaScript representation. To make a WJavaScriptHandle valid, a valid WJavaScriptHandle has to be copy-assigned to it. The various createJS... methods in WPaintedWidget return a valid handle.
std::string Wt::WJavaScriptHandle< T >::jsRef | ( | ) | const |
Returns the JavaScript representation of the object.
You can access and modify the value of this handle through its jsRef().
WException | The handle is invalid |
void Wt::WJavaScriptHandle< T >::setValue | ( | const T & | v | ) |
Set the value for this handle.
The value may not be JavaScript bound, i.e. related to another WJavaScriptHandle. The change to the value will be synced to the client side equivalent.
WException | The handle is invalid |
WException | Trying to assign a JavaScript bound value |
const T& Wt::WJavaScriptHandle< T >::value | ( | ) | const |
Get the value for this handle.
WException | The handle is invalid |