This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Bean* annotations don't work ?

No replies
Marcin Wiśnicki
Joined: 2009-11-11,
User offline. Last seen 42 years 45 weeks ago.

I can't get @BeanDisplayName and @BeanDescription to work on scala 2.8.1
and 2.9.0:


import scala.reflect._

@BeanInfo
@BeanDisplayName("Name")
@BeanDescription("Description")
class Foo {
@BeanProperty
@BeanDisplayName("bar field")
@BeanDescription("bar description")
val bar = "bar value"
}

object BeanTest {
def main(args: Array[String]): Unit = {
val info = java.beans.Introspector.getBeanInfo(classOf[Foo])
val bean = info.getBeanDescriptor
println("info: " + info)
println("bean: " + bean)
println("name: " + bean.getName)
println("displayName: " + bean.getDisplayName)
println("description: " + bean.getShortDescription)
for (p ← info.getPropertyDescriptors) {
printf("property[%s]: displayName=(%s) description=(%s)\n",
p.getName, p.getDisplayName, p.getShortDescription)
}
for (m ← info.getMethodDescriptors) {
printf("method[%s]: displayName=(%s) description=(%s)\n",
m.getName, m.getDisplayName, m.getShortDescription)
}
}
}

Output is:

info: java.beans.GenericBeanInfo@1d04653
bean: java.beans.BeanDescriptor@126804e
name: Foo
displayName: Foo
description: Foo
property[bar]: displayName=(bar) description=(bar)
method[getBar]: displayName=(getBar) description=(getBar)

Neither Foo.class nor FooBeanInfo.class contain strings that I've passed
as arguments.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland