FYI...

Thanks Steve!

---------- Forwarded message ----------
From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Jan 27, 2006 2:51 AM
Subject: Re: Struts menu - dynamic menus without JavaScript
To: [EMAIL PROTECTED]



Matt, as promised, I have uploaded a war file containing my sample struts
menu application with server-side menu state handling. Feel free to use
this
in any way.

File is at: http://sdsmith.co.uk/struts-menu.war

War file includes dependency jars to make it easy to just drop into Tomcat.

The app contains no java source code (all struts actions just forward to
the
same simple jsp page).

I've tried to document the various config files and templates, but realise
this falls far short of a complete "how to" guide - perhaps one day I'll
get
around to doing something a bit better.

As I explained before, the key to this is having each tile define its own
place in the site structure, so in this case where I have a 3 level menu
structure, each tile needs to define:

  1. top menu
  2. sub menu
  3. sub sub menu

  <put name="level1Menu" value="..." />
  <put name="level2Menu" value="..." />
  <put name="level3Menu" value="..." />

etc, etc...

Of course, this is all done by extending any parent tile, so each tile
really only needs to define its own level in the hierarchy.

Once you have done this, then in the main layout tile, you need to do:

  <tiles:useAttribute name="menuLevel1" scope="request" />
  <tiles:useAttribute name="menuLevel2" scope="request" />
  <tiles:useAttribute name="menuLevel3" scope="request" />

so we can grab the positional info from whatever body tile is loading and
stick it in the request.

The Velocity templates can then grab the positional info from the request
and can match this to the defined menu names, and write out our menu
dynamically. EG:

 #if($menu.name == $menuLevel1)
    #set($styleId="<li id='current'>")
 #else
    #set($styleId="<li>")
 #end

 $styleId<a href="$menu.url" title="$title">${title}</a></li>


My sample app has 3 levels of nesting - split into 2 chunks (top menu bar,
and side menu).  It should be easy to extend this to 4 levels (2 levels on
the top menu bar, 2 levels on the side navigation).  This should cover a
fairly huge site with a sensible navigation structure, but of course 3
levels of navigation in any one menu would start to get pretty tricky.  Of
course, with a bit of effort, it should be possible to replace my
hard-coded
menu levels with something more recursive.



Steve




    ______________________________________________________________________

----ONLINE-SERVICES-------------------------------------------
Find out more about our services or login at
http://www.scottishequitable.co.uk

-----EXISTING-BUSINESS-CONTACTS-------------------------------
08456 10 00 10 Pensions & investments ([EMAIL PROTECTED])
08456 10 00 52 Final salary pension schemes
08456 10 00 01 Online services ([EMAIL PROTECTED])
08456 00 14 02 Protection ([EMAIL PROTECTED])

**************************************************************
Scottish Equitable plc
Registered Office: Edinburgh Park, Edinburgh EH12 9SE.
Registered in Scotland (No. 144517).
Authorised and Regulated by the Financial Services Authority.
Telephone: 0870 242 6789
**************************************************************

______________________________________________________________________


                          EMAIL DISCLAIMER

This message is for the intended recipient only. It may contain
confidential or proprietary information. If you receive this message in
error, please immediately delete it, destroy all copies of it and notify
the sender.
You must not use or disclose any part of this message if you are not the
intended recipient. We may monitor all Email communication through our
networks.

If you contact us by Email, we may store your name and address to
facilitate communication.

Any views expressed in this message are those of the individual sender,
except where the message states otherwise.

We take reasonable precautions to ensure our Emails are virus free.
However, we cannot accept responsibility for any virus transmitted by us
and recommend that you subject any incoming Email to your own virus
checking procedures.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
struts-menu-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/struts-menu-user

Reply via email to