`
qmug
  • 浏览: 203423 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

菜单配置上下移功能

    博客分类:
  • J2EE
阅读更多
在数据库中



System.do?method=toMenuManager

/**
	 * 显示到菜单配置页面 
	 */
	public ActionForward toMenuManager(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		request.setAttribute("agentList", this.getPrivilegeDAO()
				.findByGroupType22(1));
		request.setAttribute("managerList", this.getPrivilegeDAO()
				.findByGroupType33(0));
		return mapping.findForward("toMenuManager");
	}


其中"agentList" 对应jsp页面中的
c:forEach var="group" items="${requestScope.agentList}" varStatus="status">
"managerList" 对应jsp页面中的
<c:forEach var="group" items="${requestScope.managerList}" varStatus="status">


this.getPrivilegeDAO() 这个
1.在action中 private PrivilegeDAO privilegeDAO; set/get 出来的
2.需要在
appilicationContext.xml
<bean name="/system"
		class="com.et.struts.action.SystemAction" singleton="false">
		<property name="privilegeDAO">
			<ref bean="privilegeDAO" />
		</property>


findByGroupType22(1)
方法
public List findByGroupType22(Integer privilegeType){// 
		String hql="from Privilege  where PrivilegeType='1' order by PIndex";
		return this.hibernateHelper.query(hql);
	}


findByGroupType33(0)

方法
public List findByGroupType33(Integer privilegeType){//
		String hql="from Privilege  where PrivilegeType='0' order by PIndex";
		return this.hibernateHelper.query(hql);
	}

 






当类型更改的时候菜单配置列表会有相应的变化



这个是jsp页面

<%@ page language="java" pageEncoding="GBK"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
    <html:base />
    
    <title>menuManager.jsp</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="../css/admin.css" type="text/css" rel="stylesheet" />
	<link href="../../css/body.css" type="text/css" rel="stylesheet" />
	<link href="agent.css" type="text/css" rel="stylesheet" />
	<script type="text/javascript" src="menu.js"></script>
	
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
  </head>
  
  <body bgcolor="#8CBAEB">
	<div class="div_main" >
		<table width="400px" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
			<tr >
				<td class="div_title" >菜单配置</td>
			</tr>
			<tr >
				<td class="div_body" bgcolor="F8FCFD">
					<form id="main" action="../../../system.do" method="post">
						<input type=hidden name=method id=method value="menuUpdate">
							<table class="div_table" bgcolor="F8FCFD"  border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#E0E0E0" >
							  
							  
					<tr>
				    <td width="17%" align="center" valign="top">类型:</td>
				    <td width="34%" align="left">
				    	<select name="type" id="type" onclick="selChange(this.value)"> 	
							<option value="1" selected="selected">坐席</option>
							<option value="0">管理</option>
						</select>
				    	&nbsp; </td>
				  </tr>		  
				  <table>
				  <tr>
				    <td width="17%" align="center" valign="top">菜单配置列表:</td>
				    <td width="34%" align="left">
			  <div id="agent1" align="center">
						<select name="agent" size="15" multiple="multiple">
						   	<c:forEach var="group" items="${requestScope.agentList}" varStatus="status">
							    <option value="${group.pid}">${group.privilegeName}</option>
						    </c:forEach>
					    </select>
						<label>
						<input type="button" name="button" value="上移" onclick="Moveup(agent)">
				    					   
				    	&nbsp;&nbsp;
				    	<input type="button" name="button" value="下移" onclick="Movedown(agent)">
				    	</label>
				</div>		    
				    	
				<div  id="manager1"  style="display: none" align="center">
						<select name="manager" size="15" multiple="multiple" >
						   	<c:forEach var="group" items="${requestScope.managerList}" varStatus="status">
							    <option value="${group.pid}">${group.privilegeName}</option>
						    </c:forEach>
						</select>
						 <label>
						<input type="button" name="button" value="上移" onclick="Moveup(manager)">
				    	</label>				   
				    	&nbsp;&nbsp; <label>
				    	<input type="button" name="button" value="下移" onclick="Movedown(manager)">
				    	</label>
				</div>	
					
						
				
				    </td>
				  </tr>
				  </table>
				  
				  
				  <tr>
				    <td height="30" colspan="2" align="center"><input name="botton" type="button" class="button1" value="提 交" onclick="toUpdate()"/>
				      &nbsp;&nbsp;&nbsp;
				       
				  </tr>
						</table>
					</form>
				</td>
			</tr>
		</table>
	</div>
  </body>
</html:html>


其中
//为了到action中
action="../../../system.do"
//为了支持JavaScript脚本
<script type="text/javascript" src="menu.js"></script>
//为了能够调用脚本中的menuUpdate方法 跳转到action中去
<input type=hidden name=method id=method value="menuUpdate">
//为了 在提交的时候有个默认被选中,否则提交的时候为空,出现问题
<option value="1" selected="selected">坐席</option>


onclick="toUpdate() 跳转到js文件中的toUpdate方法中

menu.js文件

/**
*按照类型能够取得出来下拉列表
*/
function toUpdate() {

	var typeObj = document.getElementById("type");
	//alert(typeObj.value);
	//按照管理类型把所有的列表选项都给选中
	if(typeObj.value=='0'){
		var managerObj = document.getElementById("manager");
		for (var i=0;i<managerObj.length;i++){
  			managerObj.options[i].selected=true;   
  		}
	}
	//按照坐席类型把所有的列表选项都给选中	
	if(typeObj.value=='1'){
		var agentObj = document.getElementById("agent");
		for (var i=0;i<agentObj.length;i++){
  			agentObj.options[i].selected=true;   
  		}	
	}
	//提交到action方法中
	var method = document.getElementById("method");
	method.value = "menuUpdate";
	var mainForm = document.getElementById("main");
	mainForm.submit();
}

/**
	 * 更新数据库菜单
	 */
	public ActionForward menuUpdate(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String type = request.getParameter("type");
		String groupName[] = null;
		if ("0".equals(type)) {
			groupName = request.getParameterValues("manager");
		}
		if ("1".equals(type)) {
			groupName = request.getParameterValues("agent");
		}
		if (groupName != null && groupName.length > 0) {

			this.getPrivilegeDAO().update(groupName);
		}
		return mapping.findForward("ok");
	}
分享到:
评论

相关推荐

    上下移超级列表项.rar

    在易语言中实现"上下移超级列表项"的功能,涉及到以下几个关键知识点: 1. **易语言基础**:易语言由王江民先生创建,它的设计理念是“易学易用”,提供了一种与自然语言接近的编程方式。了解易语言的基本语法、...

    JavaScript下拉菜单内容过长可以上下滑动的3级菜单,适合大多数对菜单的应用场景

    本项目提供了一个可上下滑动的3级菜单解决方案,适用于各种需要多层次菜单的场景。这种菜单设计允许用户轻松浏览长内容,提升了用户体验。 首先,我们需要理解JavaScript的基本概念。JavaScript是一种解释型的、...

    lcd1602编写的一个菜单程序

    此程序旨在实现一个基于LCD1602的菜单系统,允许用户通过串行通信接口与设备交互,进行上下移动菜单、进入子菜单或退出当前菜单的操作。 首先,我们要理解LCD1602的基本工作原理。它通常采用4线或8线的SPI或I²C...

    【Android】自定义左右滑动菜单

    MyMenu可能是源代码的主类或者库模块,开发者可以通过导入和配置这个模块,轻松地在自己的应用中实现类似的功能。 总的来说,"【Android】自定义左右滑动菜单"项目涵盖了Android UI设计、手势识别、动画实现和...

    SlidingMenu滑动菜单

    它通常被用于主屏幕的左侧或右侧,以展示更多的功能选项或者设置。用户通过简单的手势,如从屏幕边缘向内滑动,就可以打开或关闭这个菜单,这种设计极大地增强了应用的可用性和可发现性。 2. **实现原理** ...

    DataGridView实现选中复制删除上下移动置顶置尾行xml功能

    置顶功能可将选中行移到数据集的开头,置尾则移到末尾。这同样需要根据当前选中行的索引,调用`DataGridView.Rows.Insert`或`RemoveAt`方法。 6. **XML数据存储和加载**: 使用C#的`System.Xml`命名空间来处理XML...

    图形学,利用OpenGL函数进行鼠标、键盘操作,创建菜单等

    在实验描述中提到的"鼠标画线"功能,可能使用了这样的机制:当鼠标按下并移动时,记录起点和终点,然后在OpenGL上下文中绘制线条。这通常涉及`glBegin()`和`glEnd()`函数之间的顶点绘制,以及可能使用`glLineWidth()...

    Android 视图上下左右45度滑动效果.zip

    使用此类库时,开发者需要在主布局中添加菜单视图,并在Activity中初始化和配置ResideMenu。然后,通过监听触摸事件,结合ResideMenu提供的API,可以轻松地实现滑动菜单的开启和关闭。 总之,这个压缩包提供的资源...

    配置IMB_X系列的阵列卡RAID卡

    此程序内嵌于BIOS,用于配置SAS控制器,主要功能包括创建、配置、管理逻辑驱动器,以及驱动器的初始化和重新扫描。 在配置阵列前,需对硬盘进行初始化,这一步骤会清除硬盘上的所有数据和阵列信息,请谨慎操作。...

    Dell-PowerEdge服务器磁盘阵列设置.docx编程资料

    3. **激活热备功能**:在配置界面中找到热备相关的设置选项,并激活热备功能。 4. **监控状态**:定期检查热备盘的状态,确保其正常工作且随时可用。 通过以上步骤,用户可以在Dell PowerEdge服务器上成功配置磁盘...

    鼠标左右上下延伸屏幕边界 绿色中文版

    “多屏使用者更加合适”进一步强调了这个功能对于有多个显示器配置的用户来说尤其有用。多屏环境可以同时打开多个应用程序或窗口,而鼠标边缘扩展则能更顺畅地在这些窗口间导航,无需物理上大幅度移动鼠标。 “安装...

    列表li上下交换位置动画

    本主题聚焦于一个特定的应用场景——"列表li上下交换位置动画",这是一种常见于网页交互设计中的功能,特别是对于数据列表、菜单或者评分系统等元素的排序。下面将详细阐述这一知识点及其相关实现方法。 首先,我们...

    VB编辑界面IDE支持鼠标中键功能

    3. 配置VB IDE:重启VB IDE,进入“工具”菜单,找到“选项”或“插件管理器”,在其中激活或配置新安装的滚轮插件。 4. 测试功能:在代码编辑窗口中尝试使用鼠标滚轮,如果一切正常,应该可以看到代码上下滚动。 ...

    手操器BT200的使用详细讲解.doc

    1. **参数设置**:例如,将仪表的量程由0—10kPa更改为-5—25kPa,需要通过菜单进入相关参数页面,然后使用数字键设定新的上下限值。 2. **自动调零设置**:在菜单中找到零点调整选项,按照提示操作即可使仪表进入...

    大华硬盘录像机云台设置使用说明书.doc

    - **多画面模式**:在多画面显示时,将鼠标移到所需控制的通道上,右键菜单选择“云台控制”,即可打开控制窗口。 - **单画面模式**:在单画面模式下,同样通过右键菜单的“云台控制”激活控制功能。 云台控制窗口...

    Shop7z网上购物系统旗舰版 商城网站源码

    鼠标指向图片移到位置,可以对图片细节进行观看,同时支持商品图片批量上传,对已上传的图片可以重复调用,系统还支持某些行业的尺码与颜色选择功能,以及购买量的设置,同时支持网页分享与收藏功能,最大限度的留住...

    CMOS图解让你轻松了解CMOS设置

    在主菜单中你可以选择不同的设置选项,按上下左右方向键来选择,按“Enter”键进入子菜单。 1. 功能键说明 (向上键)移到上一个选项 (向下键)移到下一个选项 (向左键)移到左边的选项 (向右键)移到右边的...

    数控导出hjy_-Powermill中文教程全集.docx

    *平移模型:同时按下 SHIFT 键和鼠标键 2,移动鼠标,可将模型按鼠标移动方向平移。 *方框放大:同时按下 Ctrl 和 shift 键以及鼠标中键,画出一个方框,可放大方框所包含的区域。 *旋转模型:按下并保持鼠标中键,...

    AIM2000 ver2.0简明使用教程

    - **选项配置:** `Option`菜单包含了程序各个功能的详细设置选项,也可通过对应功能窗口内的`Option`按钮进行快速访问。 - **单位系统:** AIM2000使用原子单位体系,坐标采用波尔半径作为单位(1波尔=0....

Global site tag (gtag.js) - Google Analytics