Field field;
dotx = fieldName.lastIndexOf('.');
if (dotx < 0)
throw new BindingException(Tapestry.format("invalid-field-name", fieldName), this);
// Hm. Should validate that there's a dot!
className = fieldName.substring(0, dotx);
simpleFieldName = fieldName.substring(dotx + 1);
// Simple class names are assumed to be in the java.lang package.
if (className.indexOf('.') < 0)
className = "java.lang." + className;
try
{
targetClass = resolver.findClass(className);
}
catch (Throwable t)
{
throw new BindingException(Tapestry.format("unable-to-resolve-class", className), this, t);
}
try
{
field = targetClass.getField(simpleFieldName);
}
catch (NoSuchFieldException ex)
{
throw new BindingException(Tapestry.format("field-not-defined", fieldName), this, ex);
}
// Get the value of the field. null means look for it as a static
// variable.
try
{
value = field.get(null);
}
catch (IllegalAccessException ex)
{
throw new BindingException(Tapestry.format("illegal-field-acccess", fieldName), this, ex);
}
catch (NullPointerException ex)
{
throw new BindingException(Tapestry.format("field-is-instance", fieldName), this, ex);
}
// Don't look for it again, even if the value is itself null.
accessed = true;