2 Replies Latest reply on Feb 25, 2009 6:06 PM by Andre Fernando Salvati

    Freemarker and annotations

    Andre Fernando Salvati Novice

      Hi,


      I'm generating view code from Pojos and I was think about using annotations as a more flexible method to do that.


      Pojo:



      @Entity
      public class Acesso implements Serializable
      {
         private static final long serialVersionUID = -167586088947004386L;
      
         @Id @GeneratedValue
         private Integer id;
         private Usuario usuario;
      
         @RestricaoComEmpresa
         @ManyToOne
         @JoinColumn(name = "id_empresa")
         private Empresa empresa;
         private String introducao;
      
      ...............
      



      Now, I'm trying to access annotation from my Pojos this way:



      "entrou ${componentName} ${property.name}"
      ${pojo.decoratedObject.mappedClass.getDeclaredField(property.name).declaredAnnotations?size} 
      



      which results this:


            "entrou acesso id" 
           0 
            "entrou acesso autorizado" 
           0 
            "entrou acesso autorizado_por" 
           0 
            "entrou acesso desautorizado_por" 
           0 
            "entrou acesso empresa" 
           0 
            "entrou acesso introducao" 
           0 
      




      1) Why there's no annotations on my Field?


      2) Is there a better way to access annotations from my Field definitions?


      Thanks.