Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vertucal Menu bar based on database values

 
madhuri kh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to buils a verticle menu page for typical ecommerce site. But my menu is dynamic means the categories & leaf nodes are not fixed. I need to retrieve them from database. I searched a lot on google but most of those menus are written in javascript & DHTML & also have hardcoded menu item.
Could someone give some guidelines how to achieve this? We are using Struts framework for this project.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You say: most of those menus are written in javascript & DHTML & also have hardcoded menu item.
Yes. so what you can do in your application is generate the correct "hard-coded" JavaScript by reading the database. In the past I've done this quite succesfully. Try something like:

Note that I haven't compiled or run the above, so it's probably riddled with mistakes, but I hope you get the idea.
 
madhuri kh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx frank. My menu could have nested submenus whoes menue item are decided only after user clicks on categories. Is this possible with ur approach?
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. The approach is just the same. Find one in Javascript with hard-coded values that does what you want, then write some code to generate the same Javascript code but with your values from your database query.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic