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.
adding simple divs
How would i go about adding a simple div element in a css layout. For instance:
public class MyLayout extends CssLayout {
public MyLayout() {
//addComponent(WHAT DO I PUT HERE?);
}
}
For instance, i would like to add just 1 div:
<div class="divClass1"></div>
I need to do it without the framework adding additional extraneous divs around my div.
Thanks!
duy
Use a plain Label component. That's just one DIV on the client side, and you can set the classname of that DIV with Label.setStyleName(String)
E.g.
public class MyLayout extends CssLayout {
public MyLayout() {
Label l = new Label();
l.setSizeUndefined(); // labels are 100% wide by default
l.setStyleName("divClass1");
addComponent(l);
}
}
But since I don't know what you're needs are exactly, this might be a totally useless approach.
How to nest another component inside the div ? Doesn't seem that Labels take sub-components?
Nope, you can't put components inside a Label. You can put HTML, though, if you specify the correct Content Mode. Maybe you want a Custom Layout?
-Olli