Class WJavaScriptHandle<T extends WJavaScriptExposableObject>
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(T)
method instead.
You can access (and modify) the value of a handle on the client side using getJsRef()
.
You can update the value from the server with setValue(T)
. Currently, changes
made to the value on the client side are not synced back to the server, but
support may be added for this in the future.
Currently, only WPaintedWidget allows the use of JavaScript exposable objects
.
- See Also:
-
Method Summary
-
Method Details
-
getJsRef
Returns the JavaScript representation of the object.You can access and modify the value of this handle through its
jsRef
.Changes on the client side are currently not synced back to the server, but support for this may be added in the future.
-
setValue
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.
A defensive copy will be made of given value.
- Throws:
NullPointerException
- The given value is nullWException
- Trying to assign a JavaScript bound value
-
getValue
Get the value for this handle.- Returns:
- A copy of the value.
Warning: You should not modify this value or any copy of it on the server side, because this will not be synced to the client side. Use
setValue(T)
instead.
-