0

Generating a Menu using <ul> and <li> tags

asked 2011-10-31 20:24:09 +0800

SparkySpider gravatar image SparkySpider
444 1 3

updated 2011-10-31 20:25:46 +0800

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.

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-10-31 20:47:21 +0800

gekkio gravatar image gekkio flag of Finland
899 1
http://gekkio.fi/blog

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.

link publish delete flag offensive edit

answered 2011-11-02 09:12:54 +0800

SparkySpider gravatar image SparkySpider
444 1 3

Worked like a charm. Thank you.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-10-31 20:24:09 +0800

Seen: 234 times

Last updated: Nov 02 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More