Thanks Wendy. I will give this a try and see the results. > -----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