The API for getting involved with the way variables are resolved from gracelet scripts is in the
gracelets.api.binding
package.
The base interface
gracelets.api.binding.GraceletBindingResolver
. This interface is defined as follows:
GraceletBindingResolver.javaToggle Line Numbers |
1
package gracelets.api.binding; 2
3
4
5
6
7
@author 8
@author 9
@version 10
11
public interface GraceletBindingResolver { 12
13
14
@param 15
@return 16
17
Object resolve (Object key); 18
19
20
@link 21
22
23
@param 24
@param 25
26
void assign (Object key, Object value); 27
28
29
@link 30
31
@param 32
@return 33
34
boolean canAssign (Object key); 35
36
}
|
Every gracelet script's binding uses a composite binding resolver to get/set undeclared variable references. The default gracelets implementation defines
a set of binding resolvers, used together in the composite binding resolver in the order they are added. These are as follows:
StandardBindingResolver
This binding resolver is used to provide access to common components of the gracelets/jsf/facelets system. You can get a list of them in
the
appendix
VariableMapperBindingResolver
This allows variables that are declared and passed to facelet/gracelet templates to be resolved contextually.
BuilderContextBindingResolver
This allows the variables during building passed by tag handler to be resolvable for groovy tag source files.
VariableContextBindingResolver
This allows gracelet scripts to access the variable context (scopes like view, conversation, session, etc.,). This is the only resolver that allows assignment, in regards
to the interface canAssign() and assign() methods. This allows scripts to be able to "outject" undeclared variables into the variable context scopes.
ELBindingResolver
This will make sure that you can access EL based objects like JSF managed beans defined inside faces-config.xml
LibraryBindingResolver
This allows one to access variables available via ScriptBindings defined in
Gracelet Component Libraries.
ExtensionBindingResolver
This allows
framework extensions to be able to participate in variable resolution.
LibraryAliasBindingResolver
When a Gracelet Component Library has an alias this binding allows that alias to be used to access it instead of the namespace.
This api is available mainly for those who want to add fundamental script binding resolution to the core framework, since if all you want to do is provide
a few variables to your gracelets scripts you can use
ScriptBindings defined in a Gracelet Component Library. Also if you are integrating Gracelets
into your own framework, you can define a set of binding resolvers and add them in the order you want them to be resolved in, even mixing some of the
default Gracelet implementations if you want to. This would be done inside the implementation of the GraceletsPhaseListener.