<?xml version="1.0" encoding="UTF-8" ?>
<MenuConfig>
<Displayers>
<Displayer name="DropDown"
type="net.sf.navigator.displayer.DropDownMenuDisplayer"/>
<Displayer name="Simple"
type="net.sf.navigator.displayer.SimpleMenuDisplayer"/>
<Displayer name="CoolMenu"
type="net.sf.navigator.displayer.CoolMenuDisplayer"/>
<Displayer name="CoolMenu4"
type="net.sf.navigator.displayer.CoolMenuDisplayer4"/>
<Displayer name="MenuForm"
type="net.sf.navigator.example.PermissionsFormMenuDisplayer"/>
<Displayer name="ListMenu"
type="net.sf.navigator.displayer.ListMenuDisplayer"/>
<Displayer name="TabbedMenu"
type="net.sf.navigator.displayer.TabbedMenuDisplayer"/>
<Displayer name="Velocity"
type="net.sf.navigator.displayer.VelocityMenuDisplayer"/>
<Displayer name="XtreeMenu"
type="net.sf.navigator.displayer.XtreeMenuDisplayer"/>
<Displayer name="CSSListMenu"
type="net.sf.navigator.displayer.CSSListMenuDisplayer"/>
</Displayers>
<Menus>
<Menu name="indexMenu" title="Examples">
<!-- page attribute indicating a context relative resource.
The context path will be prepended to the value. -->
<Item name="indexMenu1" title="Basic Example"
toolTip="Shows usage of the menu displayers using defaults."
page="/menutest1.jsp"/>
<Item name="indexMenu2" title="Advanced Example"
toolTip="Shows customized menu displays."
page="/menutest2.jsp"/>
<Item name="indexMenu3" title="CoolMenu Example"
toolTip="Shows menu using CoolMenu3"
page="/coolmenu1.jsp"/>
<Item name="indexMenu4" title="CoolMenu Example - With Form"
toolTip="Shows menu using CoolMenu3 with forms."
page="/coolmenu2.jsp"/>
<Item name="indexMenu5" title="Permissions Example"
toolTip="Example use of menu disable and permission checking with CoolMenus."
page="/permissionsForm.jsp"/>
<Item name="indexMenu6" title="CoolMenu4 Example"
toolTip="Shows menu using CoolMenu4"
page="/coolmenu4.jsp"/>
<Item name="indexMenu7" title="Expandable DHTML List Example"
toolTip="Shows Expandable DHTML list"
page="/dhtmlExpandable.jsp"/>
<Item name="indexMenu7" title="Dropdown DHTML List Example"
toolTip="Shows Dropdown DHTML list"
page="/dhtmlDropdown.jsp"/>
<Item name="indexMenu8" title="Roles Menu Example"
toolTip="Shows Menus based on user's role"
page="/rolesMenu.jsp"/>
<Item name="indexMenu9" title="Tabbed Menu Example"
toolTip="Shows Tabbed-based Menu"
forward="tabbedMenu"/>
<Item title="Velocity Template Menu"
toolTip="Shows very simple Velocity generated Menu"
page="/velocity.jsp"/>
<Item title="Velocity CoolMenus Menu"
toolTip="Shows Velocity generated CoolMenu"
page="/velocity-coolmenu4.jsp"/>
<Item title="Velocity XTree Menu"
toolTip="Shows Velocity generated XTree"
page="/velocity-xtree.jsp"/>
<Item title="Velocity Tabbed Menu"
toolTip="Shows Velocity generated Tabbed Menu"
page="/velocity-tabs.jsp?Home"/>
<Item title="Nice Looking Tabbed Menu"
toolTip="Shows Velocity generated Tabbed Menu"
page="/velocity-nicetabs.jsp?Home"/>
<Item title="EL (Expression Language) enabled Menu"
toolTip="Shows very simple Velocity EL Menu"
page="/velocity-el.jsp"/>
<Item title="Dynamic, Databased-driven Menu"
toolTip="Shows very simple menu built from a database table"
page="/dynamicMenu.jsp"/>
<Item title="CSS-based Drop-down Menu: Horizontal [New!]"
toolTip="CSS-only Horizontal drop-down menu"
page="/cssHorizontal.jsp"/>
<Item title="CSS-based Drop-down: Vertical [New!]"
toolTip="CSS-only Vertical drop-down menu"
page="/cssVertical.jsp"/>
<Item title="Velocity-based CSS Drop-down Menu: Horizontal [New!]"
toolTip="Velocity-based CSS Horizontal drop-down menu"
page="/cssHorizontal.jsp?velocity=true"/>
<Item title="Velocity-based CSS Drop-down: Vertical [New!]"
toolTip="Velocity-based CSS Vertical drop-down menu"
page="/cssVertical.jsp?velocity=true"/>
</Menu>
<Menu name="projectMenu" title="Project Menu">
<Item title="Home" toolTip="Return to List of Menus" page="/index.jsp"/>
<Item title="Documentation" toolTip="View Project Documentation"
location="http://struts-menu.sf.net"/>
<Item title="FAQs" toolTip="View Frequenty Asked Questions"
location="http://struts-menu.sf.net/faq.html"/>
<Item title="Mailing Lists" toolTip="Subscribe to Mailing Lists"
location="http://sourceforge.net/mail/?group_id=48726"/>
<Item title="Mailing List Archives"
toolTip="Search the Mailing List Archives"
location="http://www.mail-archive.com/index.php?hunt=struts-menu"/>
</Menu>
<!-- ==================== To Do List Menus =========================== -->
<Menu name="ToDoListMenuFile" title="FILE" description="test" width="50">
<Item name="TDLnew" title="NEW">
<Item name="TDLnewcase" title="CASE" image="images/case-new.png"
location="NewCase.jsp"/>
<Item name="TDLnewitem" title="ITEM" image="images/item-new.png"
location="index.jsp"/>
<Item name="TDLnewparty" title="PARTY" image="images/party-new.png"
location="index.jsp"/>
</Item>
<Item name="TDLopen" title="OPEN">
<Item name="TDLopencase" title="CASE" image="images/case-open.png"
location="index.jsp"/>
<Item name="TDLopenitem" title="ITEM" image="images/item-open.png"
location="index.jsp"/>
<Item name="TDLopenparty" title="PARTY" image="images/party-open.png"
location="index.jsp"/>
</Item>
<Item name="TDLexit" title="EXIT"
image="images/exit.png" location="index.jsp"/>
</Menu>
<Menu name="ToDoListMenuEdit" title="EDIT">
<Item name="TDLselect" title="SELECT_ALL" image="images/select-all.png"
location="index.jsp" width="100" />
<Item name="TDLprefs" title="USER_PREFERENCES" image="images/prefs.png"
location="index.jsp" width="150" />
</Menu>
<Menu name="ToDoListMenuTools" title="TOOLS">
<Item name="TDLreports" title="REPORTS" image="images/reports.png"/>
<Item name="TDLfind" title="FIND" image="images/find.png"/>
<Item name="TDLsubscr" title="SUBSCRIBE" image="images/assign.png"/>
</Menu>
<Menu name="ToDoListMenuWindows" title="WINDOW">
<Item name="TDLlibr" title="LIBRARY" image="images/library.png"/>
</Menu>
<Menu name="ToDoListMenuHelp" title="HELP">
<Item name="TDLhelp" title="ONLINE_HELP" image="images/help.png"/>
<Item name="TDLabout" title="ABOUT_TRACKER" image="images/trackernet.png"/>
</Menu>
<!-- New Menu for Tabbed Displayer -->
<Menu name="TabbedHome" title="Home" location="?Home" target="_blank"/>
<Menu name="TabbedAbout" title="About"> <!-- No location, uses first item's location (People) -->
<Item name="People" title="People" location="?People"/>
<Item name="Careers" title="Careers" location="?Careers" target="_blank"/>
<Item name="Press" title="Press" location="?Press"
onclick="alert('This item has an onclick handler in menu-config.xml.')"/>
<Item name="Locations" title="Locations" location="?Locations"/>
</Menu>
<Menu name="TabbedContact" title="Contact" location="?Contact">
<Item name="EMail" title="E-Mail" location="?EMail"/>
<Item name="Phone" title="Phone" location="?Phone"/>
<Item name="CarrierPigeon" title="Carrier Pigeon" location="?Pigeon"/>
</Menu>
<Menu name="TabbedExit" title="Exit" page="/index.jsp"/>
<!-- ==================== Case View Menus =========================== -->
<!-- FILE -->
<Menu name="CaseDetailMenuFile" title="FILE" description="test">
<Item name="CDnew" title="NEW">
<Item name="CDnewcase" title="CASE" image="images/case-new.png"
location="index.jsp"/>
<Item name="CDLnewitem" title="ITEM" image="images/item-new.png"
location="index.jsp"/>
<Item name="CDnewparty" title="PARTY" image="images/party-new.png"
location="index.jsp"/>
</Item>
<Item name="CDopen" title="OPEN">
<Item name="CDopencase" title="CASE" image="images/case-open.png"
location="index.jsp"/>
<Item name="CDopenitem" title="ITEM" image="images/item-open.png"
location="index.jsp"/>
<Item name="CDopenparty" title="PARTY" image="images/party-open.png"
location="index.jsp"/>
</Item>
<Item name="CDclose" title="CLOSE" location="index.jsp"/>
<Item name="CDexit" title="EXIT"
image="images/exit.png" location="index.jsp"/>
</Menu>
<!-- EDIT -->
<Menu name="CaseDetailMenuEdit" title="EDIT">
<Item name="CDundo" title="UNDO" image="images/undo.png"/>
<Item name="CDcut" title="CUT" image="images/cut.png"/>
<Item name="CDcopy" title="COPY" image="images/copy.png"/>
<Item name="CDpaste" title="PASTE" image="images/paste.png"/>x`
<Item name="CDclear" title="CLEAR" image="images/clear.png"/>
<Item name="CDselect" title="CLEAR" image="images/select-all.png"/>
<Item name="CDprefs" title="USER_PREFERENCES" image="images/prefs.png"/>
</Menu>
<!-- CASE -->
<Menu name="CaseDetailMenuCase" title="CASE">
<Item name="CDadd" title="ADD">
<Item name="CDaddparty" title="PARTY" image="images/party-add.png"/>
<Item name="CDadditem" title="ITEM" image="images/item-add.png"/>
<Item name="CDaddcomments" title="COMMENTS" image="images/comments.png"/>
<Item name="CDadddoc" title="DOCUMENTS" image="images/documents.png"/>
<Item name="CDaddposition" title="POSITION" image="images/positions.png"/>
</Item>
<Item name="CDopen" title="OPEN">
<Item name="CDopenparty" title="PARTY" image="images/party-open.png"/>
<Item name="CDopenitem" title="ITEM" image="images/item-open.png"/>
<Item name="CDopencomments" title="COMMENTS" image="images/comments.png"/>
<Item name="CDopendoc" title="DOCUMENTS" image="images/documents.png"/>
<Item name="CDopenposition" title="POSITION" image="images/positions.png"/>
<Item name="CDopenhistory" title="HISTORY" image="images/history.png"/>
</Item>
<Item name="CDassign" title="ASSIGN" image="images/assign.png"/>
<Item name="CDactivate" title="ACTIVATE" image="images/activate.png"/>
<Item name="CDpublish" title="PUBLISH" image="images/case-pub.png"/>
<Item name="CDescalate" title="ESCALATE" image="images/escalate.png"/>
<Item name="CDdecide" title="DECIDE" image="images/decide.png"/>
<Item name="CDgenlicen" title="GENERATE_LICENSE" image="images/genlicense.png"/>
</Menu>
<Menu name="Countries" title="Countries">
<Item title="COUNTRY_AU" image="images/australia2.gif"/>
<Item title="COUNTRY_CZ" image="images/czech2.gif"/>
<Item title="COUNTRY_CN" image="images/china2.gif"/>
<Item title="COUNTRY_DK" image="images/denmark2.gif"/>
<Item title="COUNTRY_FI" image="images/finland2.gif"/>
<Item title="COUNTRY_FR" image="images/france2.gif"/>
<Item title="COUNTRY_JP" image="images/japan2.gif"/>
<Item title="COUNTRY_RU" image="images/russia2.gif"/>
<Item title="COUNTRY_US" image="images/usa2.gif"/>
<Item title="COUNTRY_CH" image="images/switzlnd2.gif"/>
</Menu>
<Menu name="Permissions" title="Permissions" roles="tomcat,role1">
<Item title="Change" location="permissionsForm.jsp"/>
</Menu>
<Menu name="Standalone" title="Standalone Test" location="?Self"/>
</Menus>
</MenuConfig>
## The displayMenu macro (at the bottom of this template) is defined in
## struts-menu.jar!/net/sf/displayer/globalMacros.vm. It has a callback to the #menuItem macro
## you see below. You can override this macro by creating a menuMacros.vm template
## at the root of your classpath
#macro( menuItem $menu $level )
<tr><td>
#foreach ($i in [0..$level])
#end
#if ($menu.url)
<a href="$menu.url" title="$displayer.getMessage($menu.title)">
$displayer.getMessage($menu.title)</a>
#else
$displayer.getMessage($menu.title)
#end
</td></tr>
#end
<table>
#displayMenu($menu 0)
</table>
package net.sf.navigator.taglib.el;
import net.sf.navigator.menu.MenuComponent;
import javax.servlet.jsp.JspException;
import java.net.MalformedURLException;
/**
* This tag acts the same as net.sf.navigator.taglib.DisplayMenuTag, except
* that it allows JSTL Expressions in it's name and target attributes.
*
* @author Matt Raible
* @version $Revision: 1.6 $ $Date: 2006/07/09 08:08:10 $
*/
public class DisplayMenuTag extends net.sf.navigator.taglib.DisplayMenuTag {
private String name;
private String target;
public void setName(String name) {
this.name = name;
}
public void setTarget(String target) {
this.target = target;
}
public DisplayMenuTag() {
super();
init();
}
private void init() {
name = null;
target = null;
}
public void release() {
super.release();
init();
}
public int doStartTag() throws JspException {
evaluateExpressions();
return super.doStartTag();
}
/**
* Overrides the setPageLocation in parentTag to use JSTL to evaluate
* the URL. It's definitely ugly, so if you have a cleaner way, please
* let me know!
*
* @param menu
*/
protected void setPageLocation(MenuComponent menu)
throws MalformedURLException, JspException {
setLocation(menu);
String url = menu.getLocation();
if (url != null) {
ExpressionEvaluator eval = new ExpressionEvaluator(this, pageContext);
menu.setUrl(eval.evalString("url", url));
}
// do all contained menus
MenuComponent[] subMenus = menu.getMenuComponents();
if (subMenus.length > 0) {
for (int i = 0; i < subMenus.length; i++) {
this.setPageLocation(subMenus[i]);
}
}
}
private void evaluateExpressions() throws JspException {
ExpressionEvaluator eval = new ExpressionEvaluator(this, pageContext);
if (name != null) {
super.setName(eval.evalString("name", name));
}
if (target != null) {
super.setTarget(eval.evalString("target", target));
}
}
}
/*
* PermissionsFormMenuDisplayer.java
*
* Created on April 30, 2002, 12:25 AM
*/
package net.sf.navigator.example;
import java.io.IOException;
import java.text.MessageFormat;
import javax.servlet.jsp.JspException;
import net.sf.navigator.displayer.SimpleMenuDisplayer;
import net.sf.navigator.menu.MenuComponent;
/**
*
* @author ssayles
*/
public class PermissionsFormMenuDisplayer extends SimpleMenuDisplayer {
//~ Static fields/initializers =============================================
private static final MessageFormat inputMessage =
new MessageFormat(
"<input type=\"checkbox\" name=\"menus\" value=\"{0}\"/>");
private static final MessageFormat itemMessage =
new MessageFormat(
"<tr><td class=\"smd-menu-item\">{0} {1} {2} {3}</td></tr>");
//~ Methods ================================================================
protected void displayComponents(MenuComponent menu, int level)
throws JspException, IOException {
String title = getMessage(menu.getTitle());
MenuComponent[] components = menu.getMenuComponents();
if (components.length > 0) {
out.println(displayStrings.getMessage("smd.menu.item.top",
getSpace(level) +
displayStrings.getMessage("smd.menu.item.image.bullet") +
getMenuInput(menu) + getMessage(menu.getTitle())));
for (int i = 0; i < components.length; i++) {
if (components[i].getMenuComponents().length > 0) {
displayComponents(components[i], level + 1);
} else {
out.println(getMenuItem(components[i], getSpace(level + 1)));
}
}
} else {
out.println(getMenuItem(menu, ""));
}
}
private String getMenuItem(MenuComponent menu, String space) {
return itemMessage.format(new String[] {
space, getMenuInput(menu), getImage(menu),
getMessage(menu.getTitle())
});
}
private String getMenuInput(MenuComponent menu) {
return inputMessage.format(new String[] { menu.getName() });
}
}
/*
* SetPermissionsActions.java
*
* Created on April 30, 2002, 1:22 AM
*/
package net.sf.navigator.example;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.navigator.menu.PermissionsAdapter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
*
* @author ssayles
*/
public final class SetPermissionsAction extends Action {
//~ Instance fields ========================================================
/**
* The <code>Log</code> instance for this application.
*/
private Log log = LogFactory.getLog(SetPermissionsAction.class);
//~ Methods ================================================================
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param actionForm The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception Exception if business logic throws an exception
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//ActionErrors errors = new ActionErrors();
String[] menus = request.getParameterValues("menus");
PermissionsAdapter permissions = new SimplePermissionsAdapter(menus);
request.getSession().setAttribute("exampleAdapter", permissions);
// added by Matt Raible to dynamically switch menus
request.getSession().setAttribute("displayer",
request.getParameter("displayer"));
return (mapping.findForward("success"));
}
}
/*
* SimplePermissionsAdapter.java
*
* Created on April 30, 2002, 1:27 AM
*/
package net.sf.navigator.example;
import java.util.ArrayList;
import net.sf.navigator.menu.MenuComponent;
import net.sf.navigator.menu.PermissionsAdapter;
/**
*
* @author ssayles
*/
public class SimplePermissionsAdapter implements PermissionsAdapter {
//~ Instance fields ========================================================
private ArrayList menuNames;
//~ Constructors ===========================================================
/**
* Creates a new instance of SimplePermissionAdapter
*/
public SimplePermissionsAdapter(String[] theMenuNames) {
menuNames = new ArrayList();
if (theMenuNames != null) {
for (int i = 0; i < theMenuNames.length; i++) {
menuNames.add(theMenuNames[i]);
}
}
}
//~ Methods ================================================================
/**
* If the menu is allowed, this should return true.
*
* @return whether or not the menu is allowed.
*/
public boolean isAllowed(MenuComponent menu) {
return !menuNames.contains(menu.getName());
}
}
分享到:
相关推荐
在你的APP中向usb-permission-issuer发送广播,申请usb权限,等申请通过在使用USB就不会弹出USB授权对话框,需要人为确认的情况。 Intent intent = new Intent(); intent.setAction("ACTION_USB_PERMISSION_ISSUER...
这个压缩包`laravel-permission-roles`可能包含了该库的源码以及示例项目,帮助开发者更好地理解和使用这个功能。 首先,我们来了解Laravel框架的基础。Laravel是由Taylor Otwell创建的一个开源PHP框架,其设计目标...
`laravel-permission`是基于Laravel的授权库,它为Laravel 5.4及更高版本提供了方便的权限和角色管理功能。这个库是由Spatie公司开发的,它允许开发者轻松地为用户分配角色并定义这些角色可以执行的操作。 首先,`...
在Laravel框架中,`laravel-menu`是一个非常实用的包,它可以帮助开发者轻松地创建和管理网站的菜单。这个包特别适用于Laravel 5版本,使得构建动态、多层和响应式的菜单变得简单易行。下面我们将深入探讨`laravel-...
在本文中,我们将深入探讨如何在Laravel框架中利用`laravel-permission`库与MongoDB数据库进行权限管理。Laravel是一个优雅的PHP框架,它提供了丰富的工具来简化Web应用的开发,而`laravel-permission`是Gates和...
$permission = Permission::create(['name' => 'edit articles']); $user->assignRole($role); $user->givePermissionTo($permission); ``` 在Laravel中,我们通常使用中间件来控制路由或控制器的访问权限。对于...
### Laravel-permission 安装与配置详解 #### 一、简介 在现代Web应用开发中,权限管理和用户角色分配是一项非常重要的功能。Laravel作为PHP领域内最受欢迎的框架之一,提供了许多优秀的扩展包来增强其功能,其中`...
在解压的文件"angular-permission-master"中,我们可以找到项目的源代码和相关资源。主要包含以下几个部分: 1. `src`目录:这是项目的主要源代码目录,包括Angular应用的所有组件、服务、管道等。 - `app`子目录...
关于基于菜单权限的动态级别要求Laravel5-6安装作曲家composer require starmoozie/dynamic-menu-permission 然后将以下行添加到数据库/种子/ DatabaseSeeder /// public function run() { $this - > call( \S ...
在本文中,我们将深入探讨基于Laravel框架的"Pencms-permission"系统,这是一个用于实现角色和权限管理的解决方案。Laravel是PHP领域中最受欢迎的Web应用程序开发框架之一,以其优雅的语法、强大的功能和丰富的生态...
d2-admin-start-kit-with-permission permission 分支 功能 路由和菜单来自同一配置文件 实现角色验证,根据用户角色动态显示菜单 对无权限路由进行拦截 下载 git clone ...
"Laravel开发-laravel-permission-command"是指Laravel的一个扩展包,专门用于处理权限相关的控制台命令,这使得权限管理变得更加便捷。本文将深入探讨这个扩展包以及Laravel中的权限系统。 Laravel权限管理的核心...
AndroidPermission6.0 AndroidPermission6.0动态权限 How to use? build.gradle compile 'com.tbruyelle.rxpermissions:rxpermissions:0.8.2@aar' compile 'io.reactivex:rxandroid:1.2.1' PermissionUtils....
在本文中,我们将深入探讨如何在Laravel框架中利用Bizzy-Permission库进行权限管理,特别是在Laravel 5.3版本中的应用。Laravel是一个优雅的PHP框架,它提供了丰富的功能来帮助开发者构建高效且可维护的Web应用程序...