Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Menu Display Problem in STRUTS ....

 
Yogesh Mathur
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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 ....

Eagerly waiting for suggestions,

Thanks in Advance...

Yogesh
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think Struts was really meant for that kind of solution.
You might be able to use logic:iterates or something, but most of what you're doing will probably require scriptlets or custom tags.
 
frisode jonge
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
like marc says, create a custom tag.

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.

Then in the jsp page call the tag at the appropriate place and display the menu the way you want. plenty of examples around. If you need javascript have a tag that creates the javascript for you dynamically, again having a vector as input.

regards,
friso
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic