Why is Vaadin so hard to extend?

Hello,

first let me say I’m do like working with Vaadin. It’s an excellent framework.
But today I had to extend the framework and experienced some in my opinion unnecessary difficulties.
My task was to support dynamic columns in our database tables. I know a ugly thing but its a requirement so why complain.

I implemented it by adding a @ElementCollection Map<String,String> to every JPA entity that needs this.
This will create an own table for each entity containing the id of the entity, the name of the column and the value.

Now I had to figure out how to combine this map in my entities with the Vaadin databinding.
First I created new implementations of com.vaadin.data.util.AbstractProperty, com.vaadin.data.util.VaadinPropertyDescriptor and BeanItem .
So far so easy:
Then I tried to extend BeanItemContainer and the problems began.

I had to overwrite the protected createBeanItem(BT bean) method to instantiate my own Implementation of BeanItem.
The method in AbstractBeanContainer uses a package private Constructor of BeanItem and the private LinkedHashMap<String, VaadinPropertyDescriptor> model.

  • Why is this Constructor BeanItem(BT bean, Map<String, VaadinPropertyDescriptor> propertyDescriptors) package private?
  • Why is there no possibly to access the “model” field of AbstractBeanItem

Access to both are important if you want to extend the functionality.
To solve these Problems I changed the Package of my own BeanItem implementation to “com.vaadin.data.util” and access the field model by reflection using Field.setAccessible(true).

That feels just wrong. The result however works perfect. My implementation is doing exactly what it should.
So why do make it so hard for me?

This was not hard, believe me Vaadin is one of the best frameworks to extend. All source code is available and if you want do something “nonstandard” you can always fork code and change it. JPAContainer is one of the heaviest addons and never will cover all users requirements. My suggestion for you is try different way of implementation dynamic columns. My implemention was based on custom field binded to one data source property which is simple Map.