|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.tapestry.binding.AbstractBinding
org.apache.tapestry.binding.ExpressionBinding
public class ExpressionBinding
Implements a dynamic binding, based on getting and fetching values using JavaBeans property access. This is built upon the OGNL library.
Optimization of the Expression
There's a lot of room for optimization here because we can
count on some portions of the expression to be
effectively static. Note that we type the root object as
IComponent. We have some expectations that
certain properties of the root (and properties reachable from the root)
will be constant for the lifetime of the binding. For example,
components never change thier page or container. This means
that certain property prefixes can be optimized:
This means that once an ExpressionBinding has been triggered,
the toString() method may return different values for the root
component and the expression than was originally set.
Identifying Invariants
Most expressions are fully dynamic; they must be resolved each time they are accessed. This can be somewhat inefficient. Tapestry can identify certain paths as invariant:
IAsset from then assets map (property assets)
IActionListener
from the listener map (property listeners)
BeanLifecycle.PAGE
lifecycle (property beans)
bindings)
These optimizations have some inherent dangers; they assume that
the components have not overidden the specified properties;
the last one (concerning helper beans) assumes that the
component does inherit from AbstractComponent.
If this becomes a problem in the future, it may be necessary to
have the component itself involved in these determinations.
| Constructor Summary | |
|---|---|
ExpressionBinding(IResourceResolver resolver,
IComponent root,
String expression,
ILocation location)
Creates a ExpressionBinding from the root object
and an OGNL expression. |
|
| Method Summary | |
|---|---|
String |
getExpression()
|
Object |
getObject()
Gets the value of the property path, with the assistance of a OGNL. |
IComponent |
getRoot()
|
boolean |
isInvariant()
Returns true if the binding is expected to always return the same value. |
void |
setBoolean(boolean value)
Constructs a Boolean and invokes IBinding.setObject(Object). |
void |
setDouble(double value)
Constructs an Double and invokes IBinding.setObject(Object). |
void |
setInt(int value)
Constructs an Integer and invokes IBinding.setObject(Object). |
void |
setObject(Object value)
Updates the property for the binding to the given value. |
void |
setString(String value)
Invokes IBinding.setObject(Object). |
String |
toString()
Returns the a String representing the property path. |
| Methods inherited from class org.apache.tapestry.binding.AbstractBinding |
|---|
createReadOnlyBindingException, getBoolean, getDouble, getInt, getLocation, getObject, getString, isWrapper |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ExpressionBinding(IResourceResolver resolver,
IComponent root,
String expression,
ILocation location)
ExpressionBinding from the root object
and an OGNL expression.
| Method Detail |
|---|
public String getExpression()
public IComponent getRoot()
public Object getObject()
BindingException - if an exception is thrown accessing the property.public boolean isInvariant()
isInvariant in interface IBindingisInvariant in class AbstractBindingpublic void setBoolean(boolean value)
IBindingBoolean and invokes IBinding.setObject(Object).
setBoolean in interface IBindingsetBoolean in class AbstractBindingpublic void setInt(int value)
IBindingInteger and invokes IBinding.setObject(Object).
setInt in interface IBindingsetInt in class AbstractBindingpublic void setDouble(double value)
IBindingDouble and invokes IBinding.setObject(Object).
setDouble in interface IBindingsetDouble in class AbstractBindingpublic void setString(String value)
IBindingIBinding.setObject(Object).
setString in interface IBindingsetString in class AbstractBindingpublic void setObject(Object value)
setObject in interface IBindingsetObject in class AbstractBindingBindingException - if the property can't be updated (typically
due to an security problem, or a missing mutator method).
BindingException - if the binding is invariant.public String toString()
extended id of the root component
and the property path ... once the binding is used, these may change
due to optimization of the property path.
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||