FormBinder FormFieldFactory Question / Issue

I’ve been using FormBinder’s ViewBoundForm without any problems until I add a FormFieldFactory.

I’ve looked through the FormBinder source code, can’t see what issue there could be, since it seems to wrap quite lightly the Vaadin Form.

What is happening right now, is that if I add a FormFieldFactory that works fine with a regular Form, the ViewBoundForm does not bind the bean values. If I omit the FormFieldFactory, it works fine.

There are no examples of using ViewBoundForm with a FormFieldFactory.

I’ve checked the fields passed to the createField method and they are correct, i.e. no “Field” at the end, which I thought might be the problem. Despite everything looking OK, the form is not bound with the values in the bean.

Anyone have any experience with FormFieldFactories and ViewBoundForm? Your input would be most welcome.


ViewBoundForm already has an internal FormFieldFactory that maps your properties to fields already created and configured in your view class. So if you replace the built in field factory with your own, things will be broken. Period. Using field factory just don’t fit well with the concept of ViewBoundForm. It should probably have field factory setter overridden and throw an exception to emphasis it.

Don’t know exactly what you are trying to do, but I guess you should just configure your fields in your view class.

If you are trying to build some part of your form automatically and want some fields to be mapped by FormBinder, don’t use ViewBoundForm. Extend PreCreatedFieldsHelper (implements FormFieldFactory) and use it together with standard Form.


Hi Matti,
Thanks for the reply. Your answer clears up why things aren’t working.

I need a FormFactory because I have an existing framework that reduces hugely working with forms. I am doing this because I have lots of simple POJOs that often share features (e.g. the same Combox appears on many pages and the values are loaded form a spreadsheet). My framework means I can create a working CRUD UI for a POJO in about 5-10 min.

Lastly, the field definitions can be shared between editable tables and forms, so no need to duplicate code there either.

So I if I understand you correctly, I would PreCreatedFieldsHelper rather than implement FormFactory to achieve the same effect.

Hope my comments made some sense.
Thanks again for the reply,

If I do that, then I loose the layout options that ViewBoundForm gives me, don’t I? Or am I missing something?

I’d like to have the automation I’ve already got and the elegance of the ViewBoundForm being able to pass a “View” form for the data.


A code example tells more than thousand words?

It might be good to add some easy hooks to ViewBoundForm for this kind of stuff. “handleNonBoundfields(…)” or something. Or fallback fiealdfactory and a fallback layout to ViewBoundForm. If you’d like to have something like this, feel free to add a feature request to the project page.


Thanks Matti for being so responsive on this issue. I’ll certainly have a look and let you know.

I’ve temporarily solved the requirement in the FormView code, but it is not the best long term solution. Thanks for your reply.