开发者

vaadin JPAcontainer and nested properties problem

开发者 https://www.devze.com 2023-03-09 13:21 出处:网络
I have entity ExchangeRate {date, currencyFrom, rate} . Entity currencyFrom has properties code and Name. I add it to container addNestedContainerProperty(\"currencyFrom.code\");

I have entity ExchangeRate {date, currencyFrom, rate} . Entity currencyFrom has properties code and Name. I add it to container addNestedContainerProperty("currencyFrom.code"); it works without problem and code is displayed in vaadin table.

Now I create BeanValidationForm开发者_Python百科 and add this field to it. It crash because BeanValidationValidator it try to find getter for currencyFrom.code and looks for method getCurrencyFrom.code inside ExchangeRate.

  1. What's wrong? How can I use nested property field on form to display some information.

  2. It's possible to modify ExchangeRate nested properties?


Answer is there: vaadin forum

  1. BeanValidationForm assumes all the properties are in the main bean class - it does not know anything about JPAContainer or nested properties. Note that JSR-303 bean validation annotations are accessed directly from the bean class, not through the container.

To get around this, you must give the correct bean class to each BeanValidationValidator created - either override BeanValidationForm.addField() and give the correct bean class to BVV.addValidator(), or use BVV directly instead of using the helper class BeanValidationForm.

  1. It should be possible (at least with suitable cascade settings) - but if you have separate EntityProviders for the class of the nested instances, they are not notified of changes if you only save the nested entity as a part of the main entity.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号