// This is all copied out of of FieldBinding!!
int dotx = _fieldName.lastIndexOf('.');
if (dotx < 0)
throw new ApplicationRuntimeException(
Tapestry.format("invalid-field-name", _fieldName));
String className = _fieldName.substring(0, dotx);
String 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;
Class targetClass = null;
try
{
targetClass = resolver.findClass(className);
}
catch (Throwable t)
{
throw new ApplicationRuntimeException(
Tapestry.format("unable-to-resolve-class", className),
t);
}
Field field = null;
try
{
field = targetClass.getField(simpleFieldName);
}
catch (NoSuchFieldException ex)
{
throw new ApplicationRuntimeException(
Tapestry.format("field-not-defined", _fieldName),
ex);
}
// Get the value of the field. null means look for it as a static
// variable.
try
{
_fieldValue = field.get(null);
}
catch (IllegalAccessException ex)
{
throw new ApplicationRuntimeException(
Tapestry.format("illegal-field-access", _fieldName),
ex);
}
catch (NullPointerException ex)
{
throw new ApplicationRuntimeException(
Tapestry.format("field-is-instance", _fieldName),
ex);
}
_fieldResolved = true;