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.
Odd CustomLayout behaviour... bug?
I've been using a CustomLayout tonight and I've noticed something a bit weird.
Here's some test code that I'm running:
String layout = "<div> Some text.<div location=\"C1\"/> Bug? Text following C1 isn't emitted</div>";
try
{
CustomLayout customLayout = new CustomLayout(new ByteArrayInputStream(layout.getBytes()));
customLayout.addComponent(new Label("test"), "C1");
return customLayout;
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
This results in "Some text. test" in the browser, but not the text following the <div location="C1"/>.
I notice that if I close the div using another tag (ie: <div location="C1"></div>) the following text is emitted. I'm not sure if the browser is relevant at this level, but I've tested it in both Safari 4.0.4 and Firefox 3.6.
Is this expected behaviour?
I'm using Vaadin 6.2.4.
I noticed this Thread identifying this as a regression.
It's a little inconvenient as my layout strings are dynamically generated using an XML processor which emits empty tags when appropriate. Fortunately forcing an XML comment in to the div, keeping it open, seems to work around the issue okay =(
I do not think this is a regression or even a bug.
<div id="a"/>
tag is not valid HTML, it must be
<div id="a"></div>
. Try creating a local file with your HTML code
<div> Some text.<div location="C1"/> Bug? Text following C1 isn't emitted</div>
Load it in Firefox and view it using Firebug. Instead of ignoring the invalid HTML Firefox tries to be smart and renders
<div>Some text<div location="C1"> Bug? Text following C1 isn't emitted</div></div>
Using that HTML obviously the "Bug?..." text will be replaced by the component as it replaces whatever is inside the div with location C1.
Thanks for your reply Artur, but according to the JavaDoc on CustomLayout and the book of vaadin, the template is XHTML =(
Your comment made me think to declare the xml namespace, but that didn't help either. Perhaps the documentation incorrect?