To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.
Java field creation using Javassist and vaadin CDI
6 years ago May 06, 2016 11:11am
I am using Viritin Forms and I want to programmatically add Vaadin fields to that form. Since Viritin/Vaadin binds the field using either its variable name or the @PropertyId annotation, I need to create a real Java field for the Vaadin field. Otherwise, binding seems to be problematic. Binding should happen to a field of a JPA class.
My thoughts were to use Javassist to create the required Java fields on the fly (that is: at runtime, and based on the annotations of the JPA class). However, this should happen before the Form class is loaded (if I modify the class afterwards, I get a "attempted duplicate class definition" exception. I also used CDI to create the form.
My question now is: how can I change the Form class (that is: adding Java fields to it) before the class is loaded. Thanks for any help.