Can caption of a component be rendered by client-side widget?

A TextField has a caption that lives in its AbstractComponentState.

When pairing up Server-side components to their client-side counter parts, is it possible to render the caption in the client-side widget?

Hi John,

Yes, that is possible. For example, Button shows its caption inside itself. You can see an example how it’s done in ButtonConnector class. Note the delegateCaptionHandling() -method which has to return false. Otherwise, layout will render the caption also.

Thank you Jarno. btw, how did you ever discover this?

I just knew where to look. Usually layout handles the positioning of the captions. Button is exception to that.

This is stated in very high level in the book of Vaadin chapter 5.3.1 (
https://vaadin.com/book/-/page/components.features.html
). However the text does not provide any code details, just pointers to Button and Panel which handle their own captions, so you still need to look at the code to find out exactly how it’s done.

Are you looking for something like the HTML “Placeholder” attribute?

Yes, I see in 5.3.1:

“Some components, such as Button and Panel, manage the caption themselves and display it inside the component.”

Thank you all.