本文主要是介绍wabacus实现(三种)返回提示信息的删除功能,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、优点:点击操作按钮时直接操作数据,并返回提示信息。缺点:不能防止误删等操作。
角色列表信息(SPRoleStatistics.xml):
<report id="report1" title="部门审批角色" parenttitle="部门审批角色request{c}" type="editablelist2"><!-- rowselect="checkbox" --><buttons><button name="button2" position="title" label="新建部门审批角色"><!-- wx_winpage('/OA/ShowReport.wx?PAGEID=WorkFlowConstitute',{width:'65%',height:'70%',title:'选择审批项进行申请'}); -->wx_alert('功能正在开发中,望耐心等候 。。。',{width:'65%',height:'70%',title:'新建部门审批角色'});</button></buttons><display><col column="c" label="个数" displaytype="hidden" /><!-- <col column="c01" label="ID" displaytype="hidden" /> --><col column="dictCode" label="角色ID" displaytype="hidden"></col><col column="c77" label="角色名称"></col><col column="gross" label="角色人数"></col><col column="{non-fromdb}" label="操作" property="look" width="100px"></col></display><sql><!-- <![CDATA[SELECT (SELECT COUNT(*) FROM (SELECT COUNT(*) FROM A01 GROUP BY c77) c)c,c77 dictCode,(SELECT dict_label FROM sys_dict_data WHERE dict_code = c77)c77,COUNT(*) gross FROM A01 GROUP BY c77]]> --><value><![CDATA[SELECT (SELECT COUNT(*) FROM (SELECT COUNT(*) FROM A01 GROUP BY c77) c)c,c77 dictCode,IF((SELECT dict_label FROM sys_dict_data WHERE dict_code = c77)IS NULL,'未分配角色',(SELECT dict_label FROM sys_dict_data WHERE dict_code = c77))c77,COUNT(*) gross FROM A01 WHERE c77!='' GROUP BY c77]]></value></sql><format><imports><import>com.wabacus.util.*</import><import>com.java.util.*</import></imports><value>rrequest.getRequest().setAttribute("c",c);//存放request,以便显示标题时能取到<![CDATA[gross = "<a href='javascript:void(0)' onclick=\"wx_alert('功能正在开发中,请耐心等待。。。',{width:'35%',height:'35%',title:'温馨提示'})\">"+ gross +"</a>";look = "<a style='line-height:21px;padding: 0 10px;background:#00B38A;border-radius:3px;display:inline-block;font-size:12px;text-decoration:none;color:white;' href='javascript:void(0)' onclick=\"wx_winpage('/OA/ShowReport.wx?PAGEID=SPUpdateRorleName&id="+dictCode+"',{width:'40%',height:'50%',title:'编辑角色'})\">编辑</a> <a style='line-height:21px;padding: 0 10px;background:#00B38A;border-radius:3px;display:inline-block;font-size:12px;text-decoration:none;color:white;' href='javascript:void(0)' onclick=\"wx_winpage('/OA/ShowReport.wx?PAGEID=SPDeleteRole&id="+dictCode+"',{width:'35%',height:'35%',title:'删除角色'})\">删除</a>";]]></value></format>
</report>
点击“删除”按钮,进入SPDeleteRole.xml,而SPDeleteRole.xml嵌入了SPDeleteRole.jsp,所以在SPDeleteRole.jsp中可以获取SPDeleteRole.xml提供的数据(ID)。
<?xml version="1.0" encoding="UTF-8"?>
<applications xmlns="http://www.wabacus.com"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.wabacus.com ../xsd/wabacus.applications.xsd"><page id="SPDeleteRole"><report id="report1" title="删除角色" type="editablelist" template="/SPWorkFlow/SPDeleteRole.jsp"><display><col column="dict_code" displaytype="hidden"></col></display><sql><select><value><![CDATA[SELECT dict_code FROM sys_dict_data WHERE {#condition#}]]></value><condition name="id" label="dict_label" hidden="true"><value><![CDATA[(dict_code = '#data#' )]]></value></condition></select></sql></report></page>
</applications>
SPDeleteRole.jsp中获取主键ID,并执行删除方法:
<%@page import="com.itextpdf.text.log.SysoLogger"%>
<%@ page language="java" contentType="text/html; charset=utf-8"pageEncoding="utf-8"%>
<%@ taglib uri="wabacus" prefix="wx"%>
<%@ pageimport="com.wabacus.system.ReportRequest,com.wabacus.util.Consts"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<style type="text/css">
</style>
</head>
<%ReportRequest rrequest = (ReportRequest) request.getAttribute("WX_REPORTREQUEST");
%>
<%String id = rrequest.getColDisplayValue("report1", "dict_code", 0); // 上传文件所在的目录
%>
<body><%@ page language="java" import="java.util.*"%><%@page import="java.sql.*"%><%String DRIVER = "com.wabacus.config.database.datasource.C3P0DataSource";String URL = "jdbc:mysql://127.0.0.1:3306/wabacusdemo?useUnicode=true&characterEncoding=GBK";String USER_NAME = "root";String PASS_WORD = "root";Class.forName(DRIVER);Connection con = DriverManager.getConnection(URL, USER_NAME, PASS_WORD);%><!-- 这样可以连接数据库.然后就写sql语句其实这些都可以写在java文件里面的 --><%String sql = "delete from sys_dict_data where dict_code='" + id + "'";PreparedStatement pstmt = con.prepareStatement(sql);pstmt.executeUpdate();pstmt.clearBatch(); // 清空缓存%><divstyle="text-align: center; height: 50%; line-height: 50%; margin-top: 50px;"><h1><font color="green">删除成功!</font></h1></div></body><script type="text/javascript">onload = function() {setInterval(go, 1500);};function go() {art.dialog.close();}
</script></html>
二、优点:能够有效地防止误删。缺点:代码量会增多,页面跳转会相对复杂一点点,但原理是相通。参考图3
三、优点:也能够有效地防止误删。缺点:代码量增多,页面跳转会相对复杂,原理相通。参考下图:
这篇关于wabacus实现(三种)返回提示信息的删除功能的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!