Class WJavaScriptHandle<T extends WJavaScriptExposableObject>
- java.lang.Object
-
- eu.webtoolkit.jwt.WJavaScriptHandle<T>
-
public class WJavaScriptHandle<T extends WJavaScriptExposableObject> extends java.lang.ObjectA 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
valueof a WJavaScriptHandle just as you would normally, with the exception that it will beJavaScript boundand 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'ssetValue(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:
WJavaScriptExposableObject,WPaintedWidget
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetJsRef()Returns the JavaScript representation of the object.TgetValue()Get the value for this handle.voidsetValue(T value)Set the value for this handle.
-
-
-
Method Detail
-
getJsRef
public java.lang.String 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
public void setValue(T value)
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:
java.lang.NullPointerException- The given value is nullWException- Trying to assign a JavaScript bound value
-
getValue
public T 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.
-
-