- 浏览: 86724 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
shu_jian:
太深奥了,看不太懂啊
声明式事务管理 -
hengstart:
谢谢了!在你这里看了不少东西,交个朋友,我也在上海java的! ...
mysql有种类型不支持事物 -
hengstart:
看不出来结果啊!什么都没有!
mysql有种类型不支持事物 -
whg333:
拉登的足球 写道最简单的方式
看的时机: 在人物的脚转到最左 ...
一张图分出你是用左脑还是右脑! -
whg333:
Jason(aijun) 写道
唯心主义者应该非常喜欢这 ...
一张图分出你是用左脑还是右脑!
---js
var UI = function(){
var ds;
var grid;
return {
init : function() {
Ext.QuickTips.init();
initDataSource();
ds.load({params:{start:0, limit:15}});
buildUI();
},
getStore: function() {
return ds;
}
};
function initDataSource(){
var recordType = Ext.data.Record.create([
{name:"id",type:"string"},
{name:"wf_id",type:"string"},
{name:"dept_name",type:"string"},
{name:"fax",type:"string"},
{name:"send_time",type:"date"}
]);
var proxy = new Ext.data.DWRProxy(AddHideColumn.getList, true);
ds = new Ext.data.Store({
proxy: proxy,
reader: new Ext.data.ListRangeReader(
{id:'id', totalProperty:'totalSize'}, recordType),
remoteSort: true
});
}
function getColumnModel(){
var columnModel = new Ext.grid.ColumnModel([{
header: 'ID',
width: 40,
align: 'center',
sortable: true,
dataIndex: 'id'
},
{
header: '流程ID',
width: 150,
align: 'left',
sortable: true,
dataIndex: 'wf_id'
},
{
header: '单位',
width: 150,
align: 'left',
sortable: true,
dataIndex: 'dept_name'
},
{
header: '传真',
width: 150,
align: 'left',
sortable: true,
dataIndex: 'fax'
},
{
header: '发送时间',
width: 150,
align: 'left',
sortable: true,
dataIndex: 'send_time',
renderer: Ext.util.Format.dateRenderer('Y-n-j G:i')
}
]);
columnModel.defaultSortable = true;
return columnModel;
}
function buildUI(){
var tb = new Ext.Toolbar( [{
text: '新建',
cls: 'x-btn-text-icon',
icon: '../images/iconNewNewsEntry.gif',
handler: function(){
showCreateUserDialog();
}
},{
text: '编辑',
cls: 'x-btn-text-icon',
icon: '../images/ed.gif',
handler : function(){
doEdit();
}
},{
text: '删除',
cls: 'x-btn-text-icon',
icon: '../images/removesmall.gif',
handler : function(){
doDel();
}
},
{
text: '机构树',
cls: 'x-btn-text-icon',
icon: '../images/search.gif',
handler : function(){
showTree();
}
}
]);
var bbar = new Ext.PagingToolbar({
pageSize: 15,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
grid = new Ext.grid.GridPanel({
store: ds,
cm: getColumnModel(),
height: 350,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
enableColumnHide: true,
enableColumnMove: true,
stripeRows: true,
tbar:tb,
bbar: bbar
});
var win = new Ext.Window({
closable: true,
width: 820,
height: 420,
x: 230,
y: 100,
plain: true,
layout: 'border',
items: [{
region: 'center',
layout: 'fit',
title: '例子',
items: [grid]
}]
});
win.show();
}
/*****************************/
//添加
function showCreateUserDialog(){
var editDialog;
var editForm;
editForm = new Ext.FormPanel({
labelAlign: 'right',
url:'',
bodyStyle:'padding:5px 5px 0',
autoScroll: true,
items:[
new Ext.form.TextField({
fieldLabel: 'ID',
name: 'id',
readOnly: false,
allowBlank:false,
width: 180,
maxLength: 32
}),
new Ext.form.TextField({
fieldLabel: '流程ID',
name: 'wfid',
readOnly: false,
allowBlank:false,
width: 180,
maxLength: 32
}),
new Ext.form.TextField({
fieldLabel: '单位',
name: 'deptname',
allowBlank:false,
width: 180,
maxLength: 50
}),
new Ext.form.TextField({
fieldLabel: '传真',
name: 'fax',
allowBlank:false,
width: 180,
maxLength: 50
}),
new Ext.form.TextField({
fieldLabel: '发送时间',
name: 'sendtime',
allowBlank:false,
width: 180,
maxLength: 50,
renderer: Ext.util.Format.dateRenderer('Y-n-j G:i')
}),
new Ext.form.Hidden({
name: 'id'
})
]
});
editDialog = new Ext.Window({
el: 'edit-user-dlg',
layout: 'fit',
width:360,
height:302,
resizable: false,
title: '编辑',
//border:false,
closeAction:'hide',
plain:true,
modal: true,
items: [editForm],
buttons: [{
text: '保存',
handler: doSaveAction
},{
text: '取消',
handler: function() {
editDialog.hide();
}
}]
});
document.getElementById("edit-user-dlg").innerHTML='';
editDialog.show();
function doSaveAction(){
var form = editForm.getForm();
if(!form.isValid()){
Ext.MessageBox.alert('提示','数据不正确');
return;
}
//保存数据
var formData = {id: '',wf_id: '',dept_name: '',fax: '',send_time: ''};
formData.id = form.findField('id').getValue();
formData.dept_name = form.findField('deptname').getValue();
formData.fax = form.findField('fax').getValue();
formData.wf_id = form.findField('wfid').getValue();
formData.send_time = form.findField('sendtime').getValue();
//alert(formData.dept_name+', ' + formData.fax + ', ' + formData.id +', ' +formData.send_time +', ' +formData.wf_id);
AddHideColumn.insert(formData,isSucc);
function isSucc(flag){
var msg = '失败';
if(flag>0){
msg = '成功';
}
Ext.MessageBox.alert('提示','操作'+msg);
editDialog.hide();
ds.reload();
}
}
}
//修改
function doEdit(){
var chks = grid.getSelections();
if(chks.length>1){
Ext.MessageBox.alert('提示','编辑时只能选择一行');
return;
}
else if(chks.length == 0){
Ext.MessageBox.alert('提示','没选择任何行');
return;
}
else{
document.getElementById("edit-user-dlg").innerHTML='';
cinfirmEdit();
}
}
function cinfirmEdit(){
var editDialog;
var editForm;
var leType = Ext.data.Record.create([
{name:"id",type:"string"},
{name:"wfid",type:"string"},
{name:"deptname",type:"string"},
{name:"fax",type:"string"},
{name:"sendtime",type:"date"}
]);
editForm = new Ext.FormPanel({
labelAlign: 'right',
url:'',
bodyStyle:'padding:5px 5px 0',
autoScroll: true,
items:[
new Ext.form.TextField({
fieldLabel: 'ID',
name: 'id',
readOnly: true,
allowBlank:false,
width: 180,
maxLength: 32
}),
new Ext.form.TextField({
fieldLabel: '流程ID',
name: 'wfid',
readOnly: false,
allowBlank:false,
width: 180,
maxLength: 32
}),
new Ext.form.TextField({
fieldLabel: '单位',
name: 'deptname',
allowBlank:false,
width: 180,
maxLength: 50
}),
new Ext.form.TextField({
fieldLabel: '传真',
name: 'fax',
allowBlank:false,
width: 180,
maxLength: 50
}),
new Ext.form.TextField({
fieldLabel: '发送时间',
name: 'sendtime',
allowBlank:false,
width: 180,
maxLength: 50,
renderer: Ext.util.Format.dateRenderer('Y-n-j G:i')
}),
new Ext.form.Hidden({
name: 'id'
})
]
});
editDialog = new Ext.Window({
el: 'edit-user-dlg',
layout: 'fit',
width:360,
height:302,
resizable: false,
title: '编辑',
//border:false,
closeAction:'hide',
plain:true,
modal: true,
items: [editForm],
buttons: [{
text: '保存',
handler: doSaveAction
},{
text: '取消',
handler: function() {
editDialog.hide();
}
}]
});
editDialog.show();
fillEditForm(); //添充表单
function doSaveAction(){
var form = editForm.getForm();
if(!form.isValid()){
Ext.MessageBox.alert('提示','数据不正确');
return;
}
//保存数据
var formData = {id: '',wf_id: '',dept_name: '',fax: '',send_time: ''};
formData.id = form.findField('id').getValue();
formData.dept_name = form.findField('deptname').getValue();
formData.fax = form.findField('fax').getValue();
formData.wf_id = form.findField('wfid').getValue();
formData.send_time = form.findField('sendtime').getValue();
//alert(formData.dept_name+', ' + formData.fax + ', ' + formData.id +', ' +formData.send_time +', ' +formData.wf_id);
AddHideColumn.insert(formData,isSucc);
function isSucc(flag){
var msg = '失败';
if(flag>0){
msg = '成功';
}
Ext.MessageBox.alert('提示','操作'+msg);
editDialog.hide();
ds.reload();
}
}
function fillEditForm(){
var chs = grid.getSelections();
var form = editForm.getForm();
var rowData = chs[0];
form.findField('wfid').setValue(rowData.get('wf_id'));
form.findField('deptname').setValue(rowData.get('dept_name'));
form.findField('fax').setValue(rowData.get('fax'));
form.findField('sendtime').setValue(rowData.get('send_time'));
form.findField('id').setValue(rowData.get('id'));
}
}
//删除
function doDel(){
var chs = grid.getSelections();
if(chs.length>0){
Ext.MessageBox.confirm('提示','是否确定删除?',confirmDel)
}
else{
Ext.MessageBox.alert('提示','还没选者要删除的行!');
}
//确认删除
function confirmDel(btn){
if(btn == 'yes'){
var itms = new Array();
for(var i=0; i<chs.length; i++){
itms.push(chs[i].get("id"));
}
AddHideColumn.deleteFax(itms,isSucc);
}
}
//是否删除成功
function isSucc(flag){
var msg = '失败';
if(flag>0){
msg = '成功';
}
Ext.MessageBox.alert('提示','操作'+msg);
ds.reload();
}
}
//显示树
function showTree(){
var nodeId;
document.getElementById("view-group-tree-dlg").innerHTML='';
var loader = new Ext.tree.DWRTreeLoader(TreeService.queryByNodeId, []);
var root = new Ext.tree.AsyncTreeNode({text: '中国', id:'1000'});
var tree = new Ext.tree.TreePanel({
id: 'deptTree',
loader:new Ext.tree.DWRTreeLoader(TreeService.queryByNodeId, {}, []),
border:false,
root:root
});
var treeEditer = new Ext.tree.TreeEditor(
Ext.getCmp('deptTree'),//将tree组建的实例放入
{
id:'tree-eidtTree',
allowBlank: false//输入的值不可以为空
}
);
tree.on('contextmenu',function(node,event){
nodeId = node.id;
event.preventDefault(); //这行是必须的
rightClick.showAt(event.getXY());//取得鼠标点击坐标,展示菜单
});
//右键菜单
var rightClick = new Ext.menu.Menu({
id :'rightClickCont',
items : [{
id:'addNode',
text : '添加',
menu:[
{
id:'insertNode',
text:'添加同级节点',
handler : function() {
showCreateUserDialog();
}
},
{
id:'appendNode',
text:'添加子节点',
handler : function(){
showCreateUserDialog();
}
}
]
}, {
id:'delNode',
text : '删除',
handler : function() {
showCreateUserDialog();
}
}, {
id:'editnode',
text : '修改',
handler : function() {
showCreateUserDialog();
}
}]
});
/*
//增加树节点
function addDialog(){
document.getElementById("addNode-Dialog").innerHTML='';
var addNodeform = new Ext.FormPanel({
labelAlign : 'right',
url : '',
bodyStyle : 'padding:5px 5px 0',
autoScroll : true,
items : [new Ext.form.TextField({
fieldLabel : '节点名称',
name : 'name',
allowBlank : false,
width : 180,
maxLength : 50
}), new Ext.form.NumberField({
fieldLabel : '节点代码',
name : 'id',
allowBlank : false,
width : 180
}),
new Ext.form.ComboBox({
fieldLabel : '是否叶子节点',
store : new Ext.data.SimpleStore({
fields : [{
name : 'label',
type : 'string'
}, {
name : 'value',
type : 'string'
}],
data : [['是', 1], ['否', 0]]
}),
editable : false,
allowBlank : false,
hiddenName : 'enabled',
displayField : 'label',
valueField : 'value',
typeAhead : true,
mode : 'local',
triggerAction : 'all',
emptyText : '设定节点...',
selectOnFocus : true,
width : 180
})]
});
var addNodeDialog = new Ext.Window({
el: 'addNode-Dialog',
layout: 'fit',
width:360,
height:302,
resizable: false,
title: '添加节点',
//border:false,
closeAction:'hide',
plain:true,
modal: true,
items: [addNodeform],
buttons: [{
text: '保存',
handler: function() {
saveNode();
}
},
{
text: '关闭',
handler: function() {
addNodeDialog.hide();
}
}
]
});
addNodeDialog.show();
//保存
function saveNode(){
var form = addNodeform.getForm();
var formData = {id: '',name: '',leaf: '',parentId:''};
formData.id = form.findField('id').getValue();
formData.name = form.findField('name').getValue();
formData.leaf = form.findField('enabled').getValue();
formData.parentId = nodeId;
//alert(formData.id+formData.name+formData.leaf+formData.parentId);
TreeService.addNode(formData,isSucc);
root.expandChildNodes(true);
//是否删除成功
function isSucc(flag){
var msg = '失败';
if(flag>0){
msg = '成功';
}
Ext.MessageBox.alert('提示','操作'+msg);
}
}
}
*/
var viewDialog = new Ext.Window({
el: 'view-group-tree-dlg',
layout: 'fit',
width:360,
height:302,
resizable: false,
title: '机构树',
//border:false,
closeAction:'hide',
plain:true,
modal: true,
items: [tree],
buttons: [{
text: '关闭',
handler: function() {
viewDialog.hide();
}
}]
});
viewDialog.show();
}
}();
Ext.onReady(UI.init, UI);
--TreeService.java
package ext.service;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ext.bean.Tree;
import ext.db.DBHelp;
public class TreeService {
/**
* 根据节点ID查找其子节点
* @param nodeId
* @return
*/
public List queryByNodeId(String nodeId){
String sql = "select id,name,isLeaf,parentId, sortOrder from Docmnt_Content ";
sql += "where parentId ='" + nodeId +"'";
List<Object> nodeList = new ArrayList<Object>();
Map<String,Object> map = null;
try{
ResultSet rs = DBHelp.getStatement().executeQuery(sql);
while(rs.next()){
boolean bl = rs.getString("isLeaf").equals("1") ? true : false;
map = new HashMap<String,Object>();
map.put("id",rs.getInt("id"));
map.put("text", rs.getString("name"));
map.put("leaf",bl );
map.put("parentId",rs.getInt("parentId"));
map.put("sortOrder",rs.getInt("sortOrder"));
map.put("expandable", !bl);
nodeList.add(map);
System.out.println(bl + rs.getString("name") + rs.getString("isLeaf"));
}
}catch(Exception ex){
ex.printStackTrace();
}
return nodeList;
}
public int addNode(Tree tree){
String sql = "insert into Docmnt_Content(id,name,isLeaf,parentId,sortOrder) values('"+ tree.getId() +"','";
sql+= tree.getName() +"','" + tree.getLeaf() +"','" + tree.getParentId() +"',0)";
try{
DBHelp.getStatement().executeQuery(sql);
}catch(Exception ex){
ex.printStackTrace();
return 0;
}
return 1;
}
}
--AddHideColumn.java
package ext.service;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.ArrayUtils;
import ext.bean.FAX;
import ext.bean.ListRange;
import ext.bean.Column;
import ext.db.DBHelp;
public class AddHideColumn {
public List queryColumns(String uid,String url){
String qSql = "select * from t_hideColumn where id='"+ uid +"' and url ='" + url +"'";
List<String> columns = null;
try{
ResultSet rs = DBHelp.getStatement().executeQuery(qSql);
if(rs.next()){
columns = new ArrayList<String>();
String col =rs.getString(3);
String colArr[] = col.split(";");
for(int i=0;i<colArr.length ;i++){
if(!"".equals(colArr[i]))
columns.add(colArr[i]);
}
}
}
catch(Exception ex){
System.out.println("查询列数据失败...");
}
return columns;
}
public ListRange getList(int startPosition, int maxResults, String orderBy){
List<FAX> list = new ArrayList<FAX>();
String qSql = "select * from zsy_fax_status_temp";
try{
ResultSet rs = DBHelp.getStatement().executeQuery(qSql);
while(rs.next()){
FAX fax = new FAX();
fax.setId(rs.getString("id"));
fax.setDept_name(rs.getString("dept_name"));
fax.setFax(rs.getString("fax"));
fax.setWf_id(rs.getString("wf_id"));
fax.setSend_time(rs.getString("send_time"));
list.add(fax);
}
}catch(Exception ex){
ex.printStackTrace();
}
FAX[] FAXArray = list.toArray(new FAX[0]);
ListRange result = new ListRange();
result.setTotalSize(list.size());
int start = startPosition;
int end = maxResults < 0 ? Integer.MAX_VALUE : start + maxResults;
result.setData(ArrayUtils.subarray(FAXArray, start, end));
return result;
}
public String insert(FAX obj){
String dSql = "delete from zsy_fax_status_temp where id='" + obj.getId() +"'";
String sql = "insert into zsy_fax_status_temp(id,wf_id,dept_name,fax,send_time) values('";
sql+= obj.getId() + "','" + obj.getWf_id() + "','" + obj.getDept_name() + "','" + obj.getFax() + "','";
sql+= obj.getSend_time() + "')";
try{
DBHelp.getStatement().execute(dSql);
DBHelp.getStatement().execute(sql);
}catch(Exception ex){
ex.printStackTrace();
System.out.println("添加数据失败...");
return "0";
}
return "1";
}
public String deleteFax(String id[]){
String sql = "delete from zsy_fax_status_temp where id ='";
try{
for(int i=0; i<id.length ;i++){
sql = sql + id[i]+"'";
DBHelp.getStatement().execute(sql);
}
}catch(Exception ex){
ex.printStackTrace();
System.out.println("删除数据失败...");
return "0";
}
return "1";
}
}
var UI = function(){
var ds;
var grid;
return {
init : function() {
Ext.QuickTips.init();
initDataSource();
ds.load({params:{start:0, limit:15}});
buildUI();
},
getStore: function() {
return ds;
}
};
function initDataSource(){
var recordType = Ext.data.Record.create([
{name:"id",type:"string"},
{name:"wf_id",type:"string"},
{name:"dept_name",type:"string"},
{name:"fax",type:"string"},
{name:"send_time",type:"date"}
]);
var proxy = new Ext.data.DWRProxy(AddHideColumn.getList, true);
ds = new Ext.data.Store({
proxy: proxy,
reader: new Ext.data.ListRangeReader(
{id:'id', totalProperty:'totalSize'}, recordType),
remoteSort: true
});
}
function getColumnModel(){
var columnModel = new Ext.grid.ColumnModel([{
header: 'ID',
width: 40,
align: 'center',
sortable: true,
dataIndex: 'id'
},
{
header: '流程ID',
width: 150,
align: 'left',
sortable: true,
dataIndex: 'wf_id'
},
{
header: '单位',
width: 150,
align: 'left',
sortable: true,
dataIndex: 'dept_name'
},
{
header: '传真',
width: 150,
align: 'left',
sortable: true,
dataIndex: 'fax'
},
{
header: '发送时间',
width: 150,
align: 'left',
sortable: true,
dataIndex: 'send_time',
renderer: Ext.util.Format.dateRenderer('Y-n-j G:i')
}
]);
columnModel.defaultSortable = true;
return columnModel;
}
function buildUI(){
var tb = new Ext.Toolbar( [{
text: '新建',
cls: 'x-btn-text-icon',
icon: '../images/iconNewNewsEntry.gif',
handler: function(){
showCreateUserDialog();
}
},{
text: '编辑',
cls: 'x-btn-text-icon',
icon: '../images/ed.gif',
handler : function(){
doEdit();
}
},{
text: '删除',
cls: 'x-btn-text-icon',
icon: '../images/removesmall.gif',
handler : function(){
doDel();
}
},
{
text: '机构树',
cls: 'x-btn-text-icon',
icon: '../images/search.gif',
handler : function(){
showTree();
}
}
]);
var bbar = new Ext.PagingToolbar({
pageSize: 15,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
grid = new Ext.grid.GridPanel({
store: ds,
cm: getColumnModel(),
height: 350,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
enableColumnHide: true,
enableColumnMove: true,
stripeRows: true,
tbar:tb,
bbar: bbar
});
var win = new Ext.Window({
closable: true,
width: 820,
height: 420,
x: 230,
y: 100,
plain: true,
layout: 'border',
items: [{
region: 'center',
layout: 'fit',
title: '例子',
items: [grid]
}]
});
win.show();
}
/*****************************/
//添加
function showCreateUserDialog(){
var editDialog;
var editForm;
editForm = new Ext.FormPanel({
labelAlign: 'right',
url:'',
bodyStyle:'padding:5px 5px 0',
autoScroll: true,
items:[
new Ext.form.TextField({
fieldLabel: 'ID',
name: 'id',
readOnly: false,
allowBlank:false,
width: 180,
maxLength: 32
}),
new Ext.form.TextField({
fieldLabel: '流程ID',
name: 'wfid',
readOnly: false,
allowBlank:false,
width: 180,
maxLength: 32
}),
new Ext.form.TextField({
fieldLabel: '单位',
name: 'deptname',
allowBlank:false,
width: 180,
maxLength: 50
}),
new Ext.form.TextField({
fieldLabel: '传真',
name: 'fax',
allowBlank:false,
width: 180,
maxLength: 50
}),
new Ext.form.TextField({
fieldLabel: '发送时间',
name: 'sendtime',
allowBlank:false,
width: 180,
maxLength: 50,
renderer: Ext.util.Format.dateRenderer('Y-n-j G:i')
}),
new Ext.form.Hidden({
name: 'id'
})
]
});
editDialog = new Ext.Window({
el: 'edit-user-dlg',
layout: 'fit',
width:360,
height:302,
resizable: false,
title: '编辑',
//border:false,
closeAction:'hide',
plain:true,
modal: true,
items: [editForm],
buttons: [{
text: '保存',
handler: doSaveAction
},{
text: '取消',
handler: function() {
editDialog.hide();
}
}]
});
document.getElementById("edit-user-dlg").innerHTML='';
editDialog.show();
function doSaveAction(){
var form = editForm.getForm();
if(!form.isValid()){
Ext.MessageBox.alert('提示','数据不正确');
return;
}
//保存数据
var formData = {id: '',wf_id: '',dept_name: '',fax: '',send_time: ''};
formData.id = form.findField('id').getValue();
formData.dept_name = form.findField('deptname').getValue();
formData.fax = form.findField('fax').getValue();
formData.wf_id = form.findField('wfid').getValue();
formData.send_time = form.findField('sendtime').getValue();
//alert(formData.dept_name+', ' + formData.fax + ', ' + formData.id +', ' +formData.send_time +', ' +formData.wf_id);
AddHideColumn.insert(formData,isSucc);
function isSucc(flag){
var msg = '失败';
if(flag>0){
msg = '成功';
}
Ext.MessageBox.alert('提示','操作'+msg);
editDialog.hide();
ds.reload();
}
}
}
//修改
function doEdit(){
var chks = grid.getSelections();
if(chks.length>1){
Ext.MessageBox.alert('提示','编辑时只能选择一行');
return;
}
else if(chks.length == 0){
Ext.MessageBox.alert('提示','没选择任何行');
return;
}
else{
document.getElementById("edit-user-dlg").innerHTML='';
cinfirmEdit();
}
}
function cinfirmEdit(){
var editDialog;
var editForm;
var leType = Ext.data.Record.create([
{name:"id",type:"string"},
{name:"wfid",type:"string"},
{name:"deptname",type:"string"},
{name:"fax",type:"string"},
{name:"sendtime",type:"date"}
]);
editForm = new Ext.FormPanel({
labelAlign: 'right',
url:'',
bodyStyle:'padding:5px 5px 0',
autoScroll: true,
items:[
new Ext.form.TextField({
fieldLabel: 'ID',
name: 'id',
readOnly: true,
allowBlank:false,
width: 180,
maxLength: 32
}),
new Ext.form.TextField({
fieldLabel: '流程ID',
name: 'wfid',
readOnly: false,
allowBlank:false,
width: 180,
maxLength: 32
}),
new Ext.form.TextField({
fieldLabel: '单位',
name: 'deptname',
allowBlank:false,
width: 180,
maxLength: 50
}),
new Ext.form.TextField({
fieldLabel: '传真',
name: 'fax',
allowBlank:false,
width: 180,
maxLength: 50
}),
new Ext.form.TextField({
fieldLabel: '发送时间',
name: 'sendtime',
allowBlank:false,
width: 180,
maxLength: 50,
renderer: Ext.util.Format.dateRenderer('Y-n-j G:i')
}),
new Ext.form.Hidden({
name: 'id'
})
]
});
editDialog = new Ext.Window({
el: 'edit-user-dlg',
layout: 'fit',
width:360,
height:302,
resizable: false,
title: '编辑',
//border:false,
closeAction:'hide',
plain:true,
modal: true,
items: [editForm],
buttons: [{
text: '保存',
handler: doSaveAction
},{
text: '取消',
handler: function() {
editDialog.hide();
}
}]
});
editDialog.show();
fillEditForm(); //添充表单
function doSaveAction(){
var form = editForm.getForm();
if(!form.isValid()){
Ext.MessageBox.alert('提示','数据不正确');
return;
}
//保存数据
var formData = {id: '',wf_id: '',dept_name: '',fax: '',send_time: ''};
formData.id = form.findField('id').getValue();
formData.dept_name = form.findField('deptname').getValue();
formData.fax = form.findField('fax').getValue();
formData.wf_id = form.findField('wfid').getValue();
formData.send_time = form.findField('sendtime').getValue();
//alert(formData.dept_name+', ' + formData.fax + ', ' + formData.id +', ' +formData.send_time +', ' +formData.wf_id);
AddHideColumn.insert(formData,isSucc);
function isSucc(flag){
var msg = '失败';
if(flag>0){
msg = '成功';
}
Ext.MessageBox.alert('提示','操作'+msg);
editDialog.hide();
ds.reload();
}
}
function fillEditForm(){
var chs = grid.getSelections();
var form = editForm.getForm();
var rowData = chs[0];
form.findField('wfid').setValue(rowData.get('wf_id'));
form.findField('deptname').setValue(rowData.get('dept_name'));
form.findField('fax').setValue(rowData.get('fax'));
form.findField('sendtime').setValue(rowData.get('send_time'));
form.findField('id').setValue(rowData.get('id'));
}
}
//删除
function doDel(){
var chs = grid.getSelections();
if(chs.length>0){
Ext.MessageBox.confirm('提示','是否确定删除?',confirmDel)
}
else{
Ext.MessageBox.alert('提示','还没选者要删除的行!');
}
//确认删除
function confirmDel(btn){
if(btn == 'yes'){
var itms = new Array();
for(var i=0; i<chs.length; i++){
itms.push(chs[i].get("id"));
}
AddHideColumn.deleteFax(itms,isSucc);
}
}
//是否删除成功
function isSucc(flag){
var msg = '失败';
if(flag>0){
msg = '成功';
}
Ext.MessageBox.alert('提示','操作'+msg);
ds.reload();
}
}
//显示树
function showTree(){
var nodeId;
document.getElementById("view-group-tree-dlg").innerHTML='';
var loader = new Ext.tree.DWRTreeLoader(TreeService.queryByNodeId, []);
var root = new Ext.tree.AsyncTreeNode({text: '中国', id:'1000'});
var tree = new Ext.tree.TreePanel({
id: 'deptTree',
loader:new Ext.tree.DWRTreeLoader(TreeService.queryByNodeId, {}, []),
border:false,
root:root
});
var treeEditer = new Ext.tree.TreeEditor(
Ext.getCmp('deptTree'),//将tree组建的实例放入
{
id:'tree-eidtTree',
allowBlank: false//输入的值不可以为空
}
);
tree.on('contextmenu',function(node,event){
nodeId = node.id;
event.preventDefault(); //这行是必须的
rightClick.showAt(event.getXY());//取得鼠标点击坐标,展示菜单
});
//右键菜单
var rightClick = new Ext.menu.Menu({
id :'rightClickCont',
items : [{
id:'addNode',
text : '添加',
menu:[
{
id:'insertNode',
text:'添加同级节点',
handler : function() {
showCreateUserDialog();
}
},
{
id:'appendNode',
text:'添加子节点',
handler : function(){
showCreateUserDialog();
}
}
]
}, {
id:'delNode',
text : '删除',
handler : function() {
showCreateUserDialog();
}
}, {
id:'editnode',
text : '修改',
handler : function() {
showCreateUserDialog();
}
}]
});
/*
//增加树节点
function addDialog(){
document.getElementById("addNode-Dialog").innerHTML='';
var addNodeform = new Ext.FormPanel({
labelAlign : 'right',
url : '',
bodyStyle : 'padding:5px 5px 0',
autoScroll : true,
items : [new Ext.form.TextField({
fieldLabel : '节点名称',
name : 'name',
allowBlank : false,
width : 180,
maxLength : 50
}), new Ext.form.NumberField({
fieldLabel : '节点代码',
name : 'id',
allowBlank : false,
width : 180
}),
new Ext.form.ComboBox({
fieldLabel : '是否叶子节点',
store : new Ext.data.SimpleStore({
fields : [{
name : 'label',
type : 'string'
}, {
name : 'value',
type : 'string'
}],
data : [['是', 1], ['否', 0]]
}),
editable : false,
allowBlank : false,
hiddenName : 'enabled',
displayField : 'label',
valueField : 'value',
typeAhead : true,
mode : 'local',
triggerAction : 'all',
emptyText : '设定节点...',
selectOnFocus : true,
width : 180
})]
});
var addNodeDialog = new Ext.Window({
el: 'addNode-Dialog',
layout: 'fit',
width:360,
height:302,
resizable: false,
title: '添加节点',
//border:false,
closeAction:'hide',
plain:true,
modal: true,
items: [addNodeform],
buttons: [{
text: '保存',
handler: function() {
saveNode();
}
},
{
text: '关闭',
handler: function() {
addNodeDialog.hide();
}
}
]
});
addNodeDialog.show();
//保存
function saveNode(){
var form = addNodeform.getForm();
var formData = {id: '',name: '',leaf: '',parentId:''};
formData.id = form.findField('id').getValue();
formData.name = form.findField('name').getValue();
formData.leaf = form.findField('enabled').getValue();
formData.parentId = nodeId;
//alert(formData.id+formData.name+formData.leaf+formData.parentId);
TreeService.addNode(formData,isSucc);
root.expandChildNodes(true);
//是否删除成功
function isSucc(flag){
var msg = '失败';
if(flag>0){
msg = '成功';
}
Ext.MessageBox.alert('提示','操作'+msg);
}
}
}
*/
var viewDialog = new Ext.Window({
el: 'view-group-tree-dlg',
layout: 'fit',
width:360,
height:302,
resizable: false,
title: '机构树',
//border:false,
closeAction:'hide',
plain:true,
modal: true,
items: [tree],
buttons: [{
text: '关闭',
handler: function() {
viewDialog.hide();
}
}]
});
viewDialog.show();
}
}();
Ext.onReady(UI.init, UI);
--TreeService.java
package ext.service;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ext.bean.Tree;
import ext.db.DBHelp;
public class TreeService {
/**
* 根据节点ID查找其子节点
* @param nodeId
* @return
*/
public List queryByNodeId(String nodeId){
String sql = "select id,name,isLeaf,parentId, sortOrder from Docmnt_Content ";
sql += "where parentId ='" + nodeId +"'";
List<Object> nodeList = new ArrayList<Object>();
Map<String,Object> map = null;
try{
ResultSet rs = DBHelp.getStatement().executeQuery(sql);
while(rs.next()){
boolean bl = rs.getString("isLeaf").equals("1") ? true : false;
map = new HashMap<String,Object>();
map.put("id",rs.getInt("id"));
map.put("text", rs.getString("name"));
map.put("leaf",bl );
map.put("parentId",rs.getInt("parentId"));
map.put("sortOrder",rs.getInt("sortOrder"));
map.put("expandable", !bl);
nodeList.add(map);
System.out.println(bl + rs.getString("name") + rs.getString("isLeaf"));
}
}catch(Exception ex){
ex.printStackTrace();
}
return nodeList;
}
public int addNode(Tree tree){
String sql = "insert into Docmnt_Content(id,name,isLeaf,parentId,sortOrder) values('"+ tree.getId() +"','";
sql+= tree.getName() +"','" + tree.getLeaf() +"','" + tree.getParentId() +"',0)";
try{
DBHelp.getStatement().executeQuery(sql);
}catch(Exception ex){
ex.printStackTrace();
return 0;
}
return 1;
}
}
--AddHideColumn.java
package ext.service;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang.ArrayUtils;
import ext.bean.FAX;
import ext.bean.ListRange;
import ext.bean.Column;
import ext.db.DBHelp;
public class AddHideColumn {
public List queryColumns(String uid,String url){
String qSql = "select * from t_hideColumn where id='"+ uid +"' and url ='" + url +"'";
List<String> columns = null;
try{
ResultSet rs = DBHelp.getStatement().executeQuery(qSql);
if(rs.next()){
columns = new ArrayList<String>();
String col =rs.getString(3);
String colArr[] = col.split(";");
for(int i=0;i<colArr.length ;i++){
if(!"".equals(colArr[i]))
columns.add(colArr[i]);
}
}
}
catch(Exception ex){
System.out.println("查询列数据失败...");
}
return columns;
}
public ListRange getList(int startPosition, int maxResults, String orderBy){
List<FAX> list = new ArrayList<FAX>();
String qSql = "select * from zsy_fax_status_temp";
try{
ResultSet rs = DBHelp.getStatement().executeQuery(qSql);
while(rs.next()){
FAX fax = new FAX();
fax.setId(rs.getString("id"));
fax.setDept_name(rs.getString("dept_name"));
fax.setFax(rs.getString("fax"));
fax.setWf_id(rs.getString("wf_id"));
fax.setSend_time(rs.getString("send_time"));
list.add(fax);
}
}catch(Exception ex){
ex.printStackTrace();
}
FAX[] FAXArray = list.toArray(new FAX[0]);
ListRange result = new ListRange();
result.setTotalSize(list.size());
int start = startPosition;
int end = maxResults < 0 ? Integer.MAX_VALUE : start + maxResults;
result.setData(ArrayUtils.subarray(FAXArray, start, end));
return result;
}
public String insert(FAX obj){
String dSql = "delete from zsy_fax_status_temp where id='" + obj.getId() +"'";
String sql = "insert into zsy_fax_status_temp(id,wf_id,dept_name,fax,send_time) values('";
sql+= obj.getId() + "','" + obj.getWf_id() + "','" + obj.getDept_name() + "','" + obj.getFax() + "','";
sql+= obj.getSend_time() + "')";
try{
DBHelp.getStatement().execute(dSql);
DBHelp.getStatement().execute(sql);
}catch(Exception ex){
ex.printStackTrace();
System.out.println("添加数据失败...");
return "0";
}
return "1";
}
public String deleteFax(String id[]){
String sql = "delete from zsy_fax_status_temp where id ='";
try{
for(int i=0; i<id.length ;i++){
sql = sql + id[i]+"'";
DBHelp.getStatement().execute(sql);
}
}catch(Exception ex){
ex.printStackTrace();
System.out.println("删除数据失败...");
return "0";
}
return "1";
}
}
发表评论
-
java.util.ConcurrentModificationException
2012-05-15 14:15 842java.util.ConcurrentModificatio ... -
Quartz在Spring中动态设置cronExpression (spring设置动态定时任务)
2010-04-15 13:35 1275什么是动态定时任务:是由客户制定生成的,服务端只知道该去执行什 ... -
Hibernate HQL查询
2009-07-09 15:32 2079Hibernate HQL查询 参数绑 ... -
editplus 编译 运行 执行 java 类
2009-03-26 16:50 1293关键字: editplus 编译 运行 执行 java 类 ... -
Resin:解决找不到com.sun.tools.javac.Main问题
2009-03-26 14:35 5211java.lang.ClassNotFoundExceptio ... -
Maven2 安装
2009-03-26 10:25 1967Maven2 安装 Maven 是一个构建工 ... -
jar打包详解
2008-10-16 15:51 1021为什么会有这个玩意呢 ... -
关于UML 2中结构图的介绍
2008-10-13 11:42 1834关于UML 2中结构图的 ... -
在 Java 中如何进行 BASE64 编码和解码
2008-10-09 09:47 1632BASE64 编码是一种常用的字符编码,在很多地方都会用到。 ... -
几种常见的异常
2008-10-08 17:12 753今天在做项目的时候报了这样一个错,所以我整理一些常见的异常,以 ... -
用PHP和MySQL保存和输出图片
2008-10-08 16:27 1421设置数据库 我们通常在数据库中所使用的文本 ... -
小议lIOC
2008-09-27 12:50 8711.ioc定义 IoC就是Inversion of Co ... -
读取显示当前目录下的文件及目录-java io
2008-09-24 18:04 2598很简单的一个需求,要求读取当前目录下所有的文件和目录,并显示出 ... -
為什么需要內部類
2008-09-24 18:00 795為什么需要內部類?有什么好處呢?感覺不用也沒什么,我也這樣任為 ... -
一个通用的ProxyMap
2008-09-19 09:23 2438先来一个通用的ProxyMap。如果不需要重用,这个类可以不用 ... -
声明式事务管理
2008-09-18 13:44 1627大多数Spring用户选择声 ... -
Spring中编程式事务处理(使用TransactionTemplate)
2008-09-18 11:39 4209Spring的编程式事务处理,需要使用Hibernate事务回 ... -
spring中使用编程级的事务
2008-09-18 10:56 2432使用org.springframework.transacti ... -
HibernateTemplate中HibernateCallback的事务
2008-09-18 10:42 1768目的:使用HibernateTemplate执行execute ... -
An internal error occurred during: Generating Art
2008-09-16 13:05 2787今天做项目遇到了这样一个问题:An internal erro ...
相关推荐
Spring+Hibernate+Ext+dwr做的一个简单的grid的增删改查,面板布局, 通过autoload方式载入grid ,以及XML树的建立 ,连接MySql数据库 。JS文件代码在Demo文件夹下,JAVA代码在src下。适合新手
总结起来,这个"struts1.2+ibatis+DWR2.0+MySql5.0增删改查的小例子"涵盖了Web开发中的一些核心技术和实践,对于初学者来说,这是一个很好的学习资源,能够帮助他们快速掌握Java Web开发的基础知识,并逐步深入到更...
综上所述,"SSH+DWR+EXT 增删改查"这个主题涉及了如何使用这些技术进行后台数据的管理。开发者可以利用SSH框架处理业务逻辑和数据持久化,通过DWR实现实时的前后端交互,再结合EXTJS创建用户友好的界面,完成网页上...
ExtJs完整例子ext+dwr,希望能给需要地兄弟提供帮助
开发者可能创建了一个EXT的界面,其中包含了一些交互元素,如按钮、表格等,当用户在前端进行操作(如点击按钮)时,DWR会触发一个后台的Java方法执行相应的业务逻辑。例如,点击按钮可能触发一个数据加载操作,DWR...
在本项目中,DWR被用来实现在不刷新整个页面的情况下进行数据的增删改查操作。用户可以通过前端界面发送请求,DWR将这些请求转换为Java方法调用,执行后返回结果,前端再根据结果更新显示,极大地提升了用户体验。 ...
在描述中提到的“一个ext+dwr的例子”,意味着这个压缩包可能包含了一个实际的示例项目,演示了如何在EXT前端应用中利用DWR进行数据交换和远程调用。具体来说,`dwrproxy.js`可能是这个示例的核心文件,它实现了EXT...
首先,EXT的主要组件包括表格、表单、面板、树形视图等,它们都具有高度可定制化和响应式设计。在EXT应用中,开发者可以通过拖拽和配置这些组件,快速搭建用户界面。DWR则负责在后台处理数据和业务逻辑,并通过Ajax...
EXT的主要优点在于它提供了大量预先封装的UI组件,如表格、树形结构、图表等,使得开发者能够快速创建出美观且功能丰富的用户界面。EXT采用MVC(Model-View-Controller)架构,有助于分离业务逻辑与视图展示,提高了...
SpringMVC和Direct Web Remoting (DWR) 是两种...以上就是"springMVC+dwr完整例子"中的主要知识点,通过这个例子,开发者可以学习如何在实际项目中结合使用这两种技术,构建一个既高效又能提供良好用户体验的Web应用。
【标题】"Ext+dwr+spring做的例子程序"是一个整合了三个关键技术的示例应用,主要展示了如何在Java Web开发中结合使用EXTJS(Ext)前端框架、Direct Web Remoting (DWR) 和Spring框架。这三个技术在现代企业级应用...
这些方法通常会处理数据的增删改查操作,例如`addNode`、`deleteNode`和`moveNode`。 2. **Java接口和实现**:定义一个接口,包含上述操作的签名。在对应的实现类中,处理实际的业务逻辑,例如与数据库交互,完成对...
EXT + DWR + Spring 是一个常见的前端与后端交互的集成解决方案,用于构建富客户端的Web应用程序。这个案例中,EXT 提供了丰富的用户界面组件,DWR (Direct Web Remoting) 实现了浏览器与服务器之间的异步通信,而...
综上所述,SSH+EXT+DWR项目结合了Struts的MVC架构、Spring的依赖管理和业务逻辑处理、Hibernate的对象关系映射、ExtJS的富客户端界面以及DWR的异步通信,形成了一套完整的Java Web开发解决方案。这个项目的实现,...
采用SSH+ajax(DWR)实现增删改查+分页的功能!!含有数据库!可以直接运行!
内含 ext+dwr+freemark+jasperreort+ireport+echance+oscache+velocite等技术 展示例子:http://zz563143188.iteye.com/blog/1462413 若要下载chm格式请到http://user.qzone.qq.com/563143188 程序源码下载地址10MB...
这个名为“ssh+ext+json+dwr技术实现的动态树”的项目结合了这些技术,为我们提供了一个生动的示例,展示了如何在实际项目中有效地整合它们。 SSH(Spring、Struts、Hibernate)是Java Web开发的三大框架,它们各自...
1.DWR 和 Ext 简单例子综合(EXT 2 和 DWR 1 表格编辑控件示例(无数据库版本)) 2.EXT 2 表格编辑控件示例(静态页面,与Java无关版本) 3.文档团队在线通讯录(Ext + DWR + MySQL 4.DWR 检查注册用户名是否存在
这个"**dwr增删改查**"的例子,正如标题和描述所提及,是一个非常基础且实用的教程,特别适合初学者了解和掌握DWR的基本用法,包括如何进行数据的添加、删除、修改和查询操作。 DWR的核心功能在于提供了一种方式,...
在这个用户管理系统中,我们可能使用了Ext的Grid Panel来展示用户列表,Form Panel来进行用户信息的增删改查,以及Tree Panel来管理组织结构。通过Ext的数据绑定机制,前端UI可以直接与后端数据源进行同步,提升了...