0

In one of our pages I've created a detail screen with some information divided in blocks. I've used HorizontalLayouts with setExpandRatio for this. Here is how this is divided (all values made black for privacy reasons):

enter image description here

The final Label of the second row (now containing ---) should actually be empty instead. All the blocks are basically Vaadin Labels, with values in it. However, these values can sometimes be null, in which case I don't want to show anything in the Label.

When I use an empty String however instead of ---, it will look like this:

enter image description here

As you can see at the final Label of the second row, it is now missing it's border (and possible other styles we might add in the future), because Vaadin automatically put the expandRatio of Labels with an empty input to 0, turning the width to 0px.

I know you can set the actual width of a Label as filler, but in this case it's simply a question whether the value that's supposed to be in that Label is or isn't null.

I've also tried a space as value, but it just ignores it and behaves the same as the empty value. And when I " " as value (without setting the Label to HTML-mode), it outputs this literally as   on the screen.

Is there any value I could use for the Label when the value is null to still show the style with borders, but without value?


EDIT: Hmm, when I use   and set the ContentMode of the Label to HTML it seems to work. Is this the intended work-around for this issue (which means I'll have to set ContentMode to HTML for all Labels with the potential of containing an empty value), or is there another workaround by changing this 'empty' value alone?

Kevin Cruijssen
  • 9,153
  • 9
  • 61
  • 135

1 Answers1

0

Ok, I ended up using my solution provided in the EDIT. For all these Labels I had already created a BorderedLabel class, so I simply added setContentMode(ContentMode.HTML); to it, and used   when the value is null in our util helper class.

Kevin Cruijssen
  • 9,153
  • 9
  • 61
  • 135