1 Jun 2011 01:25
Compiling Dynamic code - field access problems
As my first foray into Dynamic Scala land, I thought that I'd try
accessing bean properties via applyDynamic.
My first very rough cut is
trait BeanProperties extends Dynamic {
def applyDynamic(name: String)(args: Any*) = {
if (args.length == 0)
PropertyUtils.getProperty(this, name)
else
null
}
}
so that
val bean = new JTextField("text") with BeanProperties
bean.getText should equal("text")
bean.text should equal("text")
so far so good! But when I try
bean.background should equal(bean.getBackground)
the compiler complains, trying instead to give access to the field
named background rather than synthesizing a method.
variable background in class Component cannot be accessed in
javax.swing.JTextField with BeanPropertiesTest.this.BeanProperties
(Continue reading)
I just flew over 14 hours to attend it, so I hope it is "alright on the night"
RSS Feed