Important Notice - Forums is archived

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.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

How to add non-field components to a form

Aniceto Madrid
1 decade ago Mar 16, 2010 10:36am


Sometimes it's required to put in a form some components that are not fields.

For instance, I need to show a field which is html, not for edit, only to show. RichTextArea is not a choice. I cannot add a Label with HTML content because it's not a field.

How to do it?

Marko Grönroos
1 decade ago Mar 16, 2010 11:36am

You can put such extra components directly in the layout of the form. You can get the layout, which is a FormLayout by default, with getLayout().

For example:

myform.getLayout().addComponent(new Label("This is a Label"));

Binding such components to the data source of the form would need to be done manually. I'm not sure how easy that would be, there could be some issues.

Marko Grönroos
1 decade ago Mar 16, 2010 11:51am
Aniceto Madrid
1 decade ago Mar 17, 2010 1:09pm
Henri Sara
1 decade ago Mar 19, 2010 8:18am