Do I have access to annotations through freemarker?
I am rendering a form to present an annotated domain model class, i.e.:
@Entity
class User {
@NotNull
private String name;
// other code
}
I would like to read the annotated meta-data to decide how to render each property.
I would use it to add css classes to my input tags and finally use jQuery to attach validation methods on such fi开发者_如何学运维elds.
Does freemarker offer any way to access the annotated meta-data?
There may indeed be a way to do it directly, but I've gradually come to the conclusion it's simpler to do extra work in my action code to provide easier "things" for the template to consume, rather than trying to co-erce Freemark to jump through hoops.
For example, I'll create a list of booleans, one per item I'm displaying, indicating, say, whether the item has already been purchased. Freemarker is quite good at traversing parallel lists.
精彩评论