Loading...
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.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

CustomComponent vs CustomLayout

Philippe Zeitoun
5 years ago Apr 04, 2017 12:35pm
Olli Tietäväinen
5 years ago Apr 05, 2017 6:12am

Hi,

it's different technologies behind each, so it's kind of an apples vs. oranges situation. A CustomLayout is basically a HTML template that you can embed on your page with components placed at desired points. A CustomComponent allows you to make compositions of server-side components. You can even make a CustomComponent that uses a CustomLayout as its root. I personally don't use CustomLayouts that much, but they can be useful if you have very specific layouting needs. CustomComponents on the other hand are, IMO, very useful, especially for creating reusable compositions of components like dialogs with confirm and cancel buttons and so on.

-Olli

Philippe Zeitoun
5 years ago Apr 05, 2017 10:23am
Olli Tietäväinen
5 years ago Apr 05, 2017 10:33am
Nicklas Karlsson
5 years ago Apr 05, 2017 3:49pm
Philippe Zeitoun
5 years ago Apr 05, 2017 4:32pm
Nicklas Karlsson
5 years ago Apr 05, 2017 5:08pm
Olli Tietäväinen
5 years ago Apr 05, 2017 5:18pm

I guess it's something like this: If you extend a GridLayout, all of HL's constructors and methods are available to the users of MyCustomComponent
Later on, you realize you should have used a CssLayout instead. You're out of luck, people are already using newLine and other methods that can't be found in CssLayout. Use CustomComponent that has a composition root and you're safe from API-breaking changes if you decide to use a different layout as the base .

Nicklas Karlsson
5 years ago Apr 05, 2017 5:26pm