In struts-menu, the way I've implemented "active tab" is done using
JavaScript - and it's none obtrusive.  Basically, I set an onclick event on
each tab (an <li>) when the page loads.  Clicking on the tab then sets a
cookie.  When the page loads, the active tab is set by comparing the current
URL with the URLs in each menu item.  If duplicates are found (highly likely
since you might want the same menu item under different tabs), the cookie is
used.  This could also done in Java (setting the ".selected" CSS class), but
I like CSS and JavaScript, so I did it that way.

All the JavaScript can be viewed in this file:
http://raibledesigns.com/struts-menu/scripts/tabs.js

More info at http://raibledesigns.com/struts-menu/tabbedMenu.jsp?Home

HTH,

Matt

-----Original Message-----
From: Andrew Hill [mailto:[EMAIL PROTECTED]
Sent: Friday, June 06, 2003 1:36 AM
To: Struts Users Mailing List
Subject: RE: concept for active tab


Im not using tiles and tiles tabs but my app does have navigation links that
need to be highlighted.
These links come from a config file (navigation-config.xml) , which
specifies such things as the links label key and the url to which it points
(usually an action - but often with appended url parameters). (Most of my
links are in a tree and the navigation renderer uses the navigation config
to construct a javascript tree widget)

To work out which link to highlight , the renderer will compare the request
path with whats in the config. It also does some comparisons based on the
appended parameters so it knows which link to highlight when several point
at the same base action path. It seems to work quite well.

-----Original Message-----
From: Dan Allen [mailto:[EMAIL PROTECTED]
Sent: Friday, 6 June 2003 15:33
To: Struts-User List
Subject: concept for active tab


I have a site that has 6 or so main tabs.  I was thinking how I
would know which tab was active based on the page the user was
currently visiting.  I came up with one idea, but perhaps other
people have ideas as well.

In my tiles I set aside a variable name 'section' which by default
is "Home."  In each jsp page, I define the section variable to
equivalent to the section the page belongs to, else it will default
to "Home."  Then, when I render my master layout with the
navigation, I check to see if the section variable is equivalent to
the tab and if so, I display a highlighted tab.  Instead of putting
it in each jsp file I suppose I could make a mapping file of some
sort, but I haven't gotten that far yet.

Any other ideas?

Dan

--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Daniel Allen, <[EMAIL PROTECTED]>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Real programmers don't change their wardrobe too often: there
are no clothes stores that are open at two o'clock in the morning.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to