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.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
How to hide fields and labels in CustomLayout
I have the following CustomLayout, how do I hide the username and the 'User Name:' label?
I know I can hide the field through the FieldFactory, but how do I hide the Label?
My guess would be using CSS and hide the <tr> element, but how do I do that?
Thank You
<table width="100%" height="100%">
<tr height="100%">
<td>
<table align="center">
<tr>
<td align="right">User name:</td>
<td><div location="username"></div></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><div location="password"></div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<div location="okbutton"></div>
</td>
</tr>
</table>
Peter Czurak: IMy guess would be using CSS and hide the <tr> element, but how do I do that?
You need to add class names to the TR elements, and then toggle the visibility of them by adding/removing a stylename on the CustomLayout
i.e.
HTML:
<tr [b]class="label"[/b]>
<td align="right">User name:</td>
<td><div location="username"></div></td>
</tr>
Java:
CustomLayout.addStyleName("hide-labels");
CSS:
.hide-labels .label {
display: none;
}
That should work, but didn't have time to test.
Thank You!
That worked, except I had to remove the Style not add it, either way that's what I needed, thank you!
Isn't .setVisible(false) works on a label when being in a custom layout ?
Yes it does, but that only hides the field, it does not hide the table row and the label, so you'll have the row and the label visible but the data will be empty if you set the .setVisible(false) in CustomLayout