I suppose there is a minor bug in the
CoolMenuDisplayer when it is used to display mixture
of "allowed" & "not-allowed" menu items.

The problem is occured due to incorrect "Menu Item
Name" & "Menu Item Parent Name". Below is the
problematic generated JavaScript code...

oCMenu.makeMenu('Admin2','Admin', ...
oCMenu.makeMenu('null1','Admin2', ...
oCMenu.makeMenu('null2','Admin2', ...
oCMenu.makeMenu('null3','Admin2', ...

oCMenu.makeMenu('null4','Admin2', ...
oCMenu.makeMenu('null1','null4', ...
oCMenu.makeMenu('null2','null4', ...
oCMenu.makeMenu('null3','null4', ...


I have to find a workaround for the "Menu Item Name" &
"Menu Item Parent Name". Therefore, I have modified
the net.sf.navigator.displayer.CoolMenuDisplayer
accordingly...


  public void display(MenuComponent menu) 
    throws JspException, IOException
  {
    StringBuffer sb = new StringBuffer();
    buildMenuString(
      menu,
      menu.getName(),
      getParentName(menu),
      sb,
      isAllowed(menu));
    out.print(sb);
  }

  protected void buildMenuString(
    MenuComponent menu,
    String name,
    String parentName,
    StringBuffer sb,
    boolean allowed)
  {
    sb.append(menuMessage.format(getArgs(
      menu, name, parentName, allowed)));
    sb.append((allowed) ? HOVER : DIS_HOVER);
    sb.append(",'");
    sb.append((menu.getOnClick() == null) ? 
      EMPTY : menu.getOnClick());
    sb.append("')\n");

    MenuComponent[] subMenus = 
      menu.getMenuComponents();

    if (subMenus.length > 0)
    {
      for (int i = 0; i < subMenus.length; i++)
      {
        buildMenuString(
          subMenus[i],
          name + "_" + i,
          name,
          sb,
          (allowed) ? 
            isAllowed(subMenus[i]) : allowed);
      }
    }
  }

  protected String[] getArgs(
    MenuComponent menu,
    String name,
    String parentName,
    boolean allowed)
  {
    String[] args = new String[10];
    args[0] = name;
    args[1] = parentName;

    ...
    ...
    ...
  }


cheers,
kelvin yap




                
__________________________________ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
struts-menu-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/struts-menu-user

Reply via email to