Limit child content, without expand ratio

I need to create a parent container (maybe a vertical layout), that its children will be limited to their parent´s area. I´m doing that with a parentContainer with fullSize(w100% , h100%). But in this case, vaadin tries to expand child components. But i dont want that… i want a regular component addition, but the components must respect their parent area.

In order to controll the child´s height i need to setExpandRatio for every chidl.Do i need to always call setExpandRatio for this kind of problem?

Some details:

1)Parent VerticalLayout (structure) => h 100%, w 100%
– 2) Child VerticalLayout (dinamy formcontent) => h 100%, w 100%
– --3) Children of item 2. A list of components like text boxes, tables … this children should fit in its parent area, but they dont need to expand. Just occupy their parent´s area. In some cases, a child its a table with 100% height, to full fill parents area.

I´m not able to do that, because if i set parent´s height to 100% vaadin ALWAYS tries to fullfill the area.

How can i build a solution for that?

I didn’t quite understand your problem.
Do you want a maximum width so that the layout will still shrink when the parent does but expand until a certain width when possible? In this case you can add a style to the layout containing:

max-width: 100px; //e.g. limits width to 100px This also exist with min and can also be used with height.

I dont want the children to expand or shrink if they are not set to fullHeight or fullWidth.

The fact is … if the parent is 100% height, the children try to expand or distribute their height equally. I dont want that.

I just set the the parent´s height to 100% because, i need that so the child components should not overflow the parents area. Some components, like Table or treetable, dont render correctly if i dont set parents height to 100%.

Sorry for my bad english and poor explanation. Is it clear now?

Thanks!

greetings, Bruno

Here are some files with some samples…

ErorOne and ErrorTwo, are both cases that i´ve achieved. But it doesnt solves my problem.

What_i_Want.png is the thing that i want.

Thanks!
13057.png
13058.png
13059.png

I can’t test it right now but why do you try to avoid setExpandratio?

Well, Vaadin layouts do not support this dual behavior automatically. If your containing VerticalLayout has undefined size, you can’t use a component with percentual height in it.

If you want the minimum size when the container has undefined height and expansion when the component has defined size, you need an “if” somewhere that sets the height of the inner component to undefined when the containing layout has undefined height, and sets its height as 100% with expand ratio 1.0 when the height of the containing layout is defined. Most likely this if should be in the application code, which is responsible for deciding on the size of the parent.

Note that the second branch should be used when the parent has any kind of defined height - whether in pixels, percents or any other height units.

I´ll try to embed this behavior on application logic. Its kind of weird, if i tell a child component to be full sized, and need to set the expand ratio too.

Thank you all. If i get some updates, ill post here.

If you don’t set the expand ratio, the layout will split any extra space that is available evenly between all components in it. If you set it for one component, it is implicitly zero for other components in the layout. If you set it for two or more components, extra space is divided between them in the ratio of the expand ratios.

Any percentual sizes do not implicitly affect this logic, only how the component fills its slot. In practice, a percentual size other than 100% rarely makes sense in a HorizontalLayout or a VerticalLayout.

This is how Vaadin layouts have worked for many years, and if changes were made to that, a large number of applications would break on upgrade. Some of the background was in trying to make old browsers (think IE6 with all its quirks and limitations) and newer ones behave exactly the same way while supporting the full layout feature set.

Understood. About the compatibilty with older apps and browsers, i think that new Layouts classes/types or rendering mode could bring new possibilites without problems.

Thank you for the explanation Henri.