...
The $1, $2
references are Javassist constructs which allow you to specify the first and second argument passed in to the calling method.
ExpressionBinding
As stated previously, this class represents a single OGNL expression in Tapestry when used directly in html templates - such as:
No Format |
---|
<div jwcid="@Input" value="ognl:user.firstName" />
|
What you will want to examine in this class is how it deals with incrementally attempting expression evaluations using the local members _writeFailed, _accessor
. Looking through the source of this implementation will probably be the best documentation available - but keep in mind that in many instances this object also has to deal with the possibility that a write statement may never happen.
BeanProviderPropertyAccessor / Custom PropertyAccessor implementations
Besides the OgnlExpressionCompiler
logic this will probably be the second most impactual area people will have to deal with in terms of having to write new code. In this specific instance there are three new PropertyAccessor
methods you must implement in order to compile your expressions:
No Format |
---|
public Class getPropertyClass(OgnlContext context, Object target, Object name)
{
IBeanProvider provider = (IBeanProvider)target;
String beanName = ((String)name).replaceAll("\"", "");
if (provider.canProvideBean(beanName))
return provider.getBean(beanName).getClass();
return super.getPropertyClass(context, target, name);
}
public String getSourceAccessor(OgnlContext context, Object target, Object name)
{
IBeanProvider provider = (IBeanProvider)target;
String beanName = ((String)name).replaceAll("\"", "");
if (provider.canProvideBean(beanName)) {
Class type = OgnlRuntime.getCompiler().getInterfaceClass(provider.getBean(beanName).getClass());
ExpressionCompiler.addCastString(context, "((" + type.getName() + ")");
context.setCurrentAccessor(IBeanProvider.class);
context.setCurrentType(type);
return ".getBean(" + name + "))";
}
return super.getSourceAccessor(context, target, name);
}
public String getSourceSetter(OgnlContext context, Object target, Object name)
{
throw new UnsupportedCompilationException("Can't set beans on IBeanProvider.");
}
|
Although this example may not provide with all of the possible use cases you may need to learn to properly implement these methods in your own PropertyAccessor
implementations - the built in OGNL versions like ObjectPropertyAccessor, MapPropertyAccessor, ListPropertyAccessor, etc
should provide more than enough data to work from. http://svn.opensymphony.com/svn/ognl/trunk/