History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: SM-59
Type: Bug Bug
Status: Open Open
Priority: Minor Minor
Assignee: Matt Raible
Reporter: Alex Wibowo
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Struts Menu

Menu stayed highlighted after logging out

Created: 14/Sep/06 06:54 PM   Updated: 04/Mar/07 02:24 AM
Component/s: Displayers
Affects Version/s: 2.4.1
Fix Version/s: None

File Attachments: 1. File strutsmenu.war (2.45 Mb)



 Description  « Hide
Gday,

I'm currently using struts-menu 2.4.1 together with struts 1.2.7. Basically after logging in to my webapp, I use struts menu to display the menu items (to be specific, I'm using the DHTML menu style from the sample apps).
I run into a problem (minor), where the menu stays highlighted after logging out from the application. Maybe the following scenario explains it better:
1. Log in
2. Select a menu item. (will get highlighted)
3. Log out
4. Log back in.
5. The last selected menu still stays highlighted (where I would expect nothing is highlighted).

I figure out this is something related with cookies. -- and I'm pretty sure someone else has encountered this before.

Can anyone help me out?


Thanks in advance.

N.B.: Could you please reply to : netzone_tech __at__ yahoo dot com ?


Regards,

Alex.



 All   Comments   Change History   FishEye      Sort Order:
Matt Raible - 19/Sep/06 06:49 PM
Can you provide a link to which menu you're using at http://demo.raibledesigns.com/struts-menu? Can you reproduce the behavior on the demo app? Do you have a small sample app you can send so I can try to reproduce locally? I need to reproduce the problem in order to fix it. ;-)

Alex Wibowo - 25/Sep/06 11:23 PM
Hello Matt,


Thank you for the reply. I've attached a small webapp that illustrate my problem.
Basically, if the user click "submenu1" (which expand "menu1") and then click the logout link, user will be brought forward to the login page (in a normal struts app, I will bring them to the logout action which does things like session.invalidate()).

If the user logs back in, "menu1" stays expanded, and "submenu1" stays highlighted. Again, this seems to be a problem with stored cookie..


Thanks in advance for the helps!


Regards,

Alex.

Matt Raible - 03/Oct/06 02:56 PM
Yes, this is caused by the "hightlight" cookie in the following code:

function expandMenus()
{
   var menusToExpand = getCookie(menuCookie);
   if( menusToExpand != null )
   {
      // if more than one menu has been menusToExpanded,
      // create an array of menusToExpanded menus
      if( menusToExpand.indexOf(",") != -1 )
      {
         menuArray = menusToExpand.split(",");
         for( var i = 0; i < menuArray.length; i++ )
         {
            openMenu(menuArray[i]);
         }
      }
      else
      {
         openMenu(menusToExpand);
      }
   }
   var itemToHighlight = getCookie(itemCookie);
   var links = document.getElementsByTagName("a");
   // add an onclick event to set a cookie on the non-actuators
   for( i = 0; i < links.length; i++ )
   {
      if( links[i].href == itemToHighlight )
      {
         links[i].className += " highlight";
      }
   }
}

Adding an "onclick" attribute to the logout menu seems to fix the problem.

<Menu name="logoutMenu" title="Logout"
           location="login.do" onclick="deleteCookie(itemCookie)"/>

Another option would be to remove the "itemToHighlight" cookie in your logout handler.

Matt