Tweaking a layout's behavior (e.g. FormLayout) without resorting to CustomL

I’m looking into making some small tweaks to how a Layout behaves (Vaadin 7). In this case I’d like to create something just like a FormLayout, except that its captions could be components of their own (e.g. a specialized Label I’ve created) rather than the plain text caption that gets pulled off the Field. My first inclination was to extend com.vaadin.ui.FormLayout but I immediately realized it doesn’t directly implement its default two-column format; I only see a couple constructors. (Full disclosure: I haven’t dug much into the client-side parts of Vaadin. Guessing it’s somewhere in there.)

What is the best approach to accomplish my goal? I realize I could set up a CustomLayout or wrap my own GridLayout but that seems pretty drastic for this situation. Being lazy, I’d much rather piggyback on the layout that does 99% of what I want :slight_smile:



Captions in Vaadin layouts are not actually (Vaadin) components, therefore attempting to tweak any of the layouts to achieve the use of your own component will be very hard work
To be honest, setting up a custom gridlayout is almost certainly going to be your easiest/best bet. Personally, I wouldn’t say it was very drastic - certainly less drastic than trying to reimplement caption handling yourself!




Thanks Charles. I suspected my expectations were a bit naive. You have at least saved me hours of going down the wrong path.

Out of curiosity, where is all that two-column layout implemented? It might still be a good starting point, if only for observation.

com.vaadin.client.ui.VFormLayout is the client side “Widget” for handling Form Layouts. I suspect this is good for “observation” only, though… I’d just build it all on the server side from “first” principles.

Other things that all the default Vaadin Layouts handle with the captions are the Required flag (red asterisk) and the In Error flag (red exclamation icon), which I think you’d have to handle yourself - either with your custom “caption label” component, or with the field itself.

Note, I haven’t actually tried to do this myself (yet).



Fantastic – thanks again, Charles!