Layout of html field

Hi,

I’ve a problem with layouting. I have a form with two types of fields, the one line type (textfield or combobox) and the type with variable height (ListSelect or text as html)

Consider the ListSelect (“Heimatort” in the screenshot) and the html-Field (“Daten Ausländer”) read only. They are changed only via context menu. The list takes all the height it can get. I want the same behavior for the html - fields. And the html-fields should be scrollable too.

My class looks like this:

public class VaadinMultiLineTextField extends Panel implements MultiLineTextField {

	private final CustomLayout customLayout;
	
	public VaadinMultiLineTextField() {
		customLayout = new CustomLayout("");
		customLayout.addStyleName("v-html-readonly");
		customLayout.setReadOnly(true);
		customLayout.setImmediate(true);
		
		setContent(customLayout);
		setScrollable(true);

		customLayout.setHeight("50px");
	}
	
	@Override
	public void setText(String text) {
		customLayout.setTemplateContents(text != null ? text : "");
	}

If I dont do setHeight(“50px”) the box of the html - content collapses completly. setHeight(“100%”) the same.

Which idea do I miss?

Thanks

Bruno
12236.png

I believe you are applying the size to the wrong component. You should not add it to the custom layout, but to the panel around it.
So instead of customLayout.setHeight("100%"); try setHeight("100%"); or this.setHeight("100%"); (equivalent)

Hi Mathias, thank you for your message. I’ve tried your code but the field still collapses complety if it has no text content.