Does this work?
On 6/22/07, david <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've try out a simple version. I put the menu repository to application
> context with key "struts-menu-repository", as velocity treats '.' as method
> or field access, so key like "struts.menu.repository" doesn't work. And I
> also put a permission adapter "permission-adapter" to request context. $msg
> and $link are velocity struts tools.
>
> The menu.vm file:
> --------------------------------------------------------
>
> #macro(setURL $menuItem)
> #if($menuItem.components.size() > 0)
> #foreach($subMenuItem in $menuItem.components)
> #setURL($subMenuItem)
> #end
> #end
> #if(!$menuItem.url)
> #if($menuItem.page)
>
> $menuItem.setUrl($link.setRelative($menuItem.page).toString())
> #else
> #if($menuItem.forward)
>
> $menuItem.setUrl($link.setForward($menuItem.forward).toString())
> #else
> #if($menuItem.action)
>
> $menuItem.setUrl($link.setAction($menuItem.action).toString())
> #else
> #if($menuItem.location)
> $menuItem.setUrl($menuItem.location)
> #else
> #if($menuItem.components.size>0)
> $menuItem.setUrl($menuItem.components.get(0).url) #end
> #end
> #end
> #end
> #end
> #end
> #end
>
> #macro(displayMenu $menuItem $currentMenu)
> #set ($title = $msg.get($menuItem.title))
> #setURL($menuItem)
> #set ($hasSub = $menuItem.components.size() > 0)
> <li #if($hasSub)class="menubar" #end><a href="$!{menuItem.url}"
> title="$title"#if($menuItem.target)target="$menuItem.target"#end
> #if($menuItem.name.equals($currentMenu))class="current"#end>${title}</a>
> #if ($hasSub)
> <ul class="submenu">
> #foreach($subMenuItem in $menuItem.components)
> #displayMenu($subMenuItem $currentMenu)
> #end
> </ul>
> #end
> </li>
> #end
>
> <ul id="primary-nav" class="menuList">
> #set($menu-keys =
> ["MainMenu","UserMenu","FileUpload","AdminMenu","Logout"])
> #foreach($menu-key in $menu-keys)
> #set($menu = $struts-menu-repository.getMenu($menu-key))
> #if ($permission-adapter.isAllowed($menu))
> #displayMenu($menu $currentMenu) ##set current menu in your page
> #end
> #end
> </ul>
>
> -----------------------------------------
>
> David
>
>
> 在2007-06-17,"Matt Raible" <[EMAIL PROTECTED]> 写道:
>
> The Menu Repository is stuffed into the ServletContext by Struts Menu,
> so you should be able to grab it out and iterate through it. I've
> never tried it, but I've heard of others doing this.
>
> You might also look at FreeMarker which is similar to Velocity and
> allows JSP Tags. If you end up developing macros to render the menus,
> let me know - I'd love to have this type of feature in Struts Menu.
>
> Matt
>
> On 6/17/07, david <[EMAIL PROTECTED]> wrote:
> > Hi All,
> >
> > I am new to struts-menu, I have a web site with velocity for view layer.
> Now
> > I want to add struts-menu to it, can I use velocity but not JSP as
> > struts-menu's page presentation?
> >
> > Thanks and regards,
> >
> > David
> >
> >
>
>
>
> ________________________________
> 150 万 人 同 时 在 玩 的 网 游,你 不 试 试 吗 ?
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> struts-menu-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/struts-menu-user
>
>
--
http://raibledesigns.com
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
struts-menu-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/struts-menu-user