|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpivot.wtkx.Bindable
public abstract class Bindable
Base class for objects that wish to leverage WTKX binding. By extending this
class, subclasses may use the @Load
and @Bind
annotations to automate WTKX loading and binding within their class.
<Border xmlns:wtkx="http://incubator.apache.org/pivot/wtkx/1.1" xmlns="pivot.wtk"> <content> <FlowPane orientation="vertical"> <Slider wtkx:id="redSlider" bounds="{minimum:0, maximum:255}" value="0"/> <Slider wtkx:id="greenSlider" bounds="{minimum:0, maximum:255}" value="0"/> <Slider wtkx:id="blueSlider" bounds="{minimum:0, maximum:255}" value="0"/> <Border wtkx:id="colorBorder" preferredWidth="120" preferredHeight="30"/> </FlowPane> </content> </Border>You could leverage WTKX binding by subclassing Bindable, like so:
public class Example extends Bindable { @Load(resourceName="example.wtkx") private Border border; @Bind(fieldName="border") private Slider redSlider; @Bind(fieldName="border") private Slider greenSlider; @Bind(fieldName="border") private Slider blueSlider; @Bind(fieldName="border", id="colorBorder") private Border colorSample; public Example() { // Your annotated variables will be null until you call bind() bind(); } }
BindProcessor
, is available
and will cause the binding process to load the WTKX at runtime and bind
the values to the variables without the use of reflection. This
method requires the use of a Sun javac compiler; it is suitable
for callers that are willing to adopt a dependency on Sun's compiler in
order to function in an untrusted environment.
BindProcessor
Nested Class Summary | |
---|---|
protected static interface |
Bindable.Bind
Annotation that causes a loaded WTKX element to be bound to the annotated field. |
protected static interface |
Bindable.Load
Annotation that causes the annotated field to be loaded via WTKX and bound to the field. |
static interface |
Bindable.ObjectHierarchy
Interface denoting a WTKX object hierarchy to which we can bind values. |
Constructor Summary | |
---|---|
protected |
Bindable()
Creates a new Bindable object. |
Method Summary | |
---|---|
protected void |
bind()
Applies WTKX binding annotations to this object. |
protected void |
bind(Dictionary<String,Bindable.ObjectHierarchy> objectHierarchies)
This is an internal method that callers should neither invoke nor override. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Bindable()
Method Detail |
---|
protected final void bind() throws BindException
Note that by default, this method uses reflection to perform the binding. This may necessitate a call to setAccessible(true) on the bound field. If there is a security manager, its checkPermission method will correspondingly be called with a ReflectPermission("suppressAccessChecks") permission. This permission is not granted to un-trusted applets, meaning that this method of binding is not available to un-signed applets.
To mitigate this problem, a compile-time annotation processor,
BindProcessor
, is available and will cause this method to work
without requiring the use of reflection. This in turn will eliminate any
security issues with the binding process.
BindException
- If an error occurs during bindingprotected void bind(Dictionary<String,Bindable.ObjectHierarchy> objectHierarchies)
BindProcessor
. Dealing directly
with this method in any way may yield unpredictable behavior.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |