I am stuck with a very peculiar problem in STRUTS...
I am making a web application where the menu's are generated dynamically by loading them from database.
I have a menu table, from where I get the menu id, menu name, menu level and parent menu flag.
Menu ID is primary key (DB2 TIMESTAMP), Menu name is name of menu, menu level describes what level should the menu be displayed at. For ex: if menu level = 0, it is a top level menu. It can have its children menu with menu level = 1. Similarly menu level 1 can have children with menu level = 2
I need to display these in order: first the top level menu (menu level = 0) below it its children(menu level = 1) second level menu(menu level = 2)
another top level menu (menu level = 0) 1st level children (menu level = 1)
..... and so on ...
I am getting the list of menu's, sorted in the order they have to be displayed in a vector with the four fields as menu id, menu name, menu level & parent menu flag. Parent menu flag is to indicate weather this menu has got children or not, so that I could know that I have reached the end of a tree and have no children menu's further.
I have to iterate through this vector in my jsp page and display the menus in indented format based on their level..
Ex: Top Level Menu 1 First Level 1 First Level 2 Second Level 1
Top Level Menu 2 First Level 1 Second Level 1
.... and so on...
I have to put tabs based on the menu level, for 0 level no tab, for 1 level 1 tab, for 2 level 2 tabs .. and so on..
I need some solution as to how can I achieve this using STRUTS ....
first in your action, you call a helper which goes to the database and creates the vector (hmm, still jvm 1.1 ?). Then save the vector in the request and have the action map to a jsp page (like normal struts)
second, create a custom tag which has input of a vector and which creates html as output.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop