Hi Wendy, I have just changed tabs.js javascript and make the tab get highlighted. I did not change any Action's code. It's working great. Here is the function activateMenu():
function activateMenu() { var menu = document.getElementById("menuList"); var items = menu.getElementsByTagName("li"); var activeMenu; var found = 0; for (var i=0; i < items.length; i++) { var url = items[i].firstChild.getAttribute("href"); var appNamePos = url.lastIndexOf("/"); var appPath = url.substring(0, appNamePos); var current = document.location.toString(); if (current.indexOf(appPath) != -1) { found++; } } // more than one found, use cookies if (found > 1) { var menuSelected = getCookie("menuSelected"); //default to 0 if there is no cookie, to avoid an error if ( menuSelected == null ) { menuSelected=0; setCookie("menuSelected", menuSelected); } if (items[menuSelected].parentNode.className == "submenu") { items[menuSelected].firstChild.className="selected"; items[menuSelected].parentNode.parentNode.className="selected"; } else { items[menuSelected].className+="selected"; } } else { // only one found, match on URL for (var i=0; i < items.length; i++) { var url = items[i].firstChild.getAttribute("href"); var current = document.location.toString(); if (current.indexOf(url) != -1) { if (items[i].parentNode.className == "submenu") { items[i].firstChild.className="selected"; items[i].parentNode.parentNode.className="selected"; } else { items[i].className+="selected"; } } } } } Thank you, Reddy Pingili Raleigh, NC > -----Original Message----- > From: Wendy Smoak [SMTP:[EMAIL PROTECTED] > Sent: Friday, February 27, 2004 4:36 PM > To: [EMAIL PROTECTED] > Subject: Re: [struts-menu] Wrong 'tab' selected > > > Hi Wendy, > > Have you managed to set the cookie in an Action (that knows what > > tab it will forward to) and make the proper tab get highlighted? > > If you have any suggestions or changes, please post them here or on my > Wiki: > http://wiki.wendysmoak.com/cgi-bin/wiki.pl?StrutsMenuTabs > > I have this in the Action code: > > private static String STANDARD = "0"; > private static String ADVANCED = "1"; > private static String COOKIE_NAME = "menuSelected"; > > private void setCookie( HttpServletRequest request, HttpServletResponse > response, String tab ) > { > Cookie cookie = getCookie( request, COOKIE_NAME ); > if ( cookie == null ) { > cookie = new Cookie( COOKIE_NAME, null ); //might need to be "" > instead of null > } > > if ( !tab.equals(cookie.getValue() ) ) { > cookie.setValue( tab ); > cookie.setMaxAge( 2592000 ); //one month? > cookie.setComment( "Foundation Accounting reporting tab" ); > response.addCookie( cookie ); > } > } > > Then elsewhere in the Action, it's either: > setCookie( request, response, STANDARD ); > return mapping.getInputForward(); > or > setCookie( request, response, ADVANCED ); > return mapping.findForward( "advanced" ); > (I only have two tabs.) > > > If so, have you changed tabs.js javascript also? > > function activateMenu() { > var menu = document.getElementById("menuList"); > var items = menu.getElementsByTagName("li"); > var menuSelected = getCookie("menuSelected"); > //default to 0 if there is no cookie, to avoid an error > if ( typeof( menuSelected ) == "undefined" ) { menuSelected=0; } > items[menuSelected].className+="selected"; > } > > > Can you share your experience on this effort? > > It works fine for me. Note that the setCookie code above has been > modified > and not fully tested yet. The original was too embarrassing to post. ;) > It > compiles, but I'm not sure about passing null to the Cookie constructor. > > -- > Wendy Smoak > Chandler, AZ > > > > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. > Build and deploy apps & Web services for Linux with > a free DVD software kit from IBM. Click Now! > http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click > _______________________________________________ > struts-menu-user mailing list > [EMAIL PROTECTED] > https://lists.sf.net/lists/listinfo/struts-menu-user ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ struts-menu-user mailing list [EMAIL PROTECTED] https://lists.sf.net/lists/listinfo/struts-menu-user