-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi there,
I tried to generate a very dynamic menu by saying:
myDiv.appendChild(new Html("<li>Hello</li>")
This almost worked fine, except that I kept getting everything enclosed in <span> elements. I then got smart and tried out the HtmlNativeComponent() object.
myDiv.appendChild(new HtmlNativeComponent("<li>Hello</li>")
This came out unreadable, something like this:
<<li>Hello<</li/>
Weird.
I then tried
myDiv.appendChild(new HtmlNativeComponent("li")
Which seems to produce the output that I want, but I got an "Uncompilable Code. Erroneous Tree Type" error.
Any advice, much appreciated.
If you want to update those li elements dynamically, you can use html components from org.zkoss.zhtml package (org.zkoss.zhtml.Li). They work just like normal components so your code would become:
Li li = new Li(); li.appendChild(new Label("Hello")); myDiv.appendChild(li);
Please note that you need to have the zhtml JAR package in your classpath. It's ZK CE stuff, so the license is LGPL just like with zul components.
Worked like a charm. Thank you.
Asked: 2011-10-31 20:24:09 +0800
Seen: 234 times
Last updated: Nov 02 '11