js 文件:
Ext.BLANK_IMAGE_URL = basePath + 'ext/resources/images/default/s.gif';
Ext.SSL_SECURE_URL = basePath + 'ext/resources/images/default/s.gif';
var baseUrl = basePath + 'AjaxListener?className=com.dvision.digitalplatform.bizApp.tisInfo.ttsInfo';
var tree_unit = '';
var tree_unit_id = '0';
Ext.onReady(function(){
Ext.QuickTips.init();
//--------------------------------------------------------------------------------------------------------------------------------------------
var reader = new Ext.data.JsonReader({
id : 'ID',
root : 'root',
totalProperty : 'totalProperty',
fields : ['TSIP','TSINNUM','TSPORT','TSOUTNUM','TSID']
});
var openUrl = baseUrl;
openUrl += '&methodName=getTTS';
openUrl += '¶mCount=2';
roleStore = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : openUrl
}),
reader : reader
});
roleStore.load({
params : {
param_0 : 0,
param_1 : 19
}
});
var bbar = new Ext.PagingToolbar({
id:'bb',
pageSize : 19,
store:roleStore,
storeParams : {
className : 'com.dvision.digitalplatform.bizApp.ttsInfo',
methodName : 'getTTS',
paramCount : '2',
param_0 : '0',
param_1 : '19'
},
paramNames : {
start : 'param_0',
limit : 'param_1'
},
displayInfo : true,
displayMsg : "显示 {0} - {1},共 {2}条",
emptyMsg : '没有数据需要分页',
stripeRows : true,
items : ['-']
});
var sm1 = new Ext.grid.CheckboxSelectionModel({
singleSelect : false
});
var grid = new Ext.grid.GridPanel({
id :'grid',
width: Ext.get('tabs1').getWidth(),
ds : roleStore,
cm : new Ext.grid.ColumnModel([
sm1,
{
width : 140,
header : '转发ID',
align : 'left',
dataIndex : 'TSID',
sortable:true
},
{
width : 140,
header : '转发IP',
align : 'left',
dataIndex : 'TSIP'
},
{
width : 140,
header : '转发端口',
align : 'left',
dataIndex : 'TSPORT'
}
,
{
id : 'tsinnum',
width : 140,
header : '传入码流数量',
align : 'left',
dataIndex : 'TSINNUM'
}
,
{
width : 140,
header : '传出码流数量',
align : 'left',
dataIndex : 'TSOUTNUM'
}
]),
sm:sm1,
width : 1345,
height :430,
frame: false,
fill : true,
bbar :bbar
});
setInterval(function(){
roleStore.reload(); // dataStore 换成你的 store 的变量名
}, 2000); //每隔 1 秒
grid.addListener('cellclick', cellclick);
function cellclick(grid, rowIndex, columnIndex, e) {
// var record = grid.getStore().getAt(rowIndex); //Get the Record
// var fieldName = grid.getColumnModel().getDataIndex(columnIndex); //Get field name
//var data = record.get(fieldName);
// Ext.MessageBox.alert('show');
// Ext.MessageBox.alert('wo xxxxx',columnIndex);
sel = grid.getSelectionModel().getSelections();
var a =sel[0].data.TSID;
// Ext.MessageBox.alert(sel[0].data.TSID);
if(columnIndex==5){
var reader4 = new Ext.data.JsonReader({
id : 'ID',
root : 'root',
totalProperty : 'totalProperty',
fields : ['DEVICENAME','TSOUTID','USERIP','USERPORT','TSID','USERID','CHANNELNAME']
});
var openUrl4 = baseUrl;
openUrl4 += '&methodName=getTISOUT';
openUrl4 += '¶mCount=3';
// openUrl += '¶m_0=0';
// openUrl += '¶m_1=10';
roleStore4 = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : openUrl4
}),
reader : reader4
});
roleStore4.baseParams['param_2']=a;
roleStore4.removeAll();
//Ext.getCmp('cx').setDisabled(true);
roleStore4.reload({
params:{
className : 'com.dvision.digitalplatform.bizApp.ttsInfor',
methodName : 'getTISOUT',
paramCount : '3',
param_0 : 0,
param_1 : 15,
param_2 : a
}
});
grid.getView().refresh();
var bbar4 = new Ext.PagingToolbar({
id:'bb',
pageSize : 19,
store:roleStore4,
storeParams : {
className : 'com.dvision.digitalplatform.bizApp.ttsInfo',
methodName : 'getTISOUT',
paramCount : '3',
param_0 : '0',
param_1 : '19',
param_2 : a
},
paramNames : {
start : 'param_0',
limit : 'param_1',
str : a
},
displayInfo : true,
displayMsg : "显示 {0} - {1},共 {2}条",
emptyMsg : '没有数据需要分页',
stripeRows : true,
items : ['-']
});
var sm4 = new Ext.grid.CheckboxSelectionModel({
singleSelect : false
});
win=new Ext.Window({
id : 'popWin',
layout : 'fit',
title : '转发传出信息',
anchor : '50%',
width : 760,
height : 400,
closeAction : 'close',
plain : true,
modal : true,
items : [
new Ext.grid.GridPanel({
id :'grid4',
width: Ext.get('tabs1').getWidth(),
ds : roleStore4,
cm : new Ext.grid.ColumnModel([
sm4,
{
width : 120,
header : '转发传出信息ID',
align : 'left',
dataIndex : 'TSOUTID',
sortable:true
},
{
width : 70,
header : '转发ID',
align : 'left',
dataIndex : 'TSID'
},
{
width : 70,
header : '用户ID',
align : 'left',
dataIndex : 'USERID'
},
{
width : 120,
header : '用户IP',
align : 'left',
dataIndex : 'USERIP'
}
,
{
width : 100,
header : '用户端口',
align : 'left',
dataIndex : 'USERPORT'
}
,
{
width : 110,
header : '设备名称',
align : 'left',
dataIndex : 'DEVICENAME'
},
{
width : 110,
header : '通道名称',
align : 'left',
dataIndex : 'CHANNELNAME'
}
]),
sm:sm4,
width : 1345,
height :430,
frame: false,
fill : true,
bbar :bbar4,
tbar : [ {
text : '关闭',
handler : function() {
win.close();
}
}]
})
]
})
win.show();
setInterval(function() {
roleStore4.reload(); // dataStore 换成你的 store 的变量名
}, 2000); //每隔 1 秒
}
if(columnIndex==4){
var reader3 = new Ext.data.JsonReader({
id : 'ID',
root : 'root',
totalProperty : 'totalProperty',
fields : ['TSINID','ISID','DEVICENAME','TSID','CHANNELNAME']
});
var openUrl3 = baseUrl;
openUrl3 += '&methodName=getTTSIN';
openUrl3 += '¶mCount=3';
// openUrl += '¶m_0=0';
// openUrl += '¶m_1=10';
roleStore3 = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : openUrl3
}),
reader : reader3
});
roleStore3.baseParams['param_2']=a;
roleStore3.removeAll();
//Ext.getCmp('cx').setDisabled(true);
roleStore3.reload({
params:{
className : 'com.dvision.digitalplatform.bizApp.ttsInfor',
methodName : 'getTTSIN',
paramCount : '3',
param_0 : 0,
param_1 : 15,
param_2 : a
}
});
grid.getView().refresh();
var bbar3 = new Ext.PagingToolbar({
id:'bb',
pageSize : 15,
store:roleStore3,
storeParams : {
className : 'com.dvision.digitalplatform.bizApp.ttsInfo',
methodName : 'getTTSIN',
paramCount : '3',
param_0 : '0',
param_1 : '15',
param_2 : a
},
paramNames : {
start : 'param_0',
limit : 'param_1',
str : a
},
displayInfo : true,
displayMsg : "显示 {0} - {1},共 {2}条",
emptyMsg : '没有数据需要分页',
stripeRows : true,
items : ['-']
});
var sm3 = new Ext.grid.CheckboxSelectionModel({
singleSelect : false
});
win=new Ext.Window({
id : 'popWin',
layout : 'fit',
title : '转发传入信息',
anchor : '50%',
width : 700,
height : 400,
closeAction : 'close',
plain : true,
modal : true,
items : [
new Ext.grid.GridPanel({
id :'grid3',
width: Ext.get('tabs1').getWidth(),
ds : roleStore3,
cm : new Ext.grid.ColumnModel([
sm3,
{
width : 130,
header : '转发传入信息ID',
align : 'left',
dataIndex : 'TSINID',
sortable:true
},
{
width : 130,
header : '转发ID',
align : 'left',
dataIndex : 'TSID'
},
{
width : 130,
header : '接口ID',
align : 'left',
dataIndex : 'ISID'
}
,
{
width : 130,
header : '设备名称',
align : 'left',
dataIndex : 'DEVICENAME'
}
,
{
width : 130,
header : '通道名称',
align : 'left',
dataIndex : 'CHANNELNAME'
}
]),
sm:sm3,
width : 1345,
height :430,
frame: false,
fill : true,
bbar :bbar3,
tbar : [ {
text : '关闭',
handler : function() {
win.close();
}
}]
})
]
});
win.show();
setInterval(function() {
roleStore3.reload(); // dataStore 换成你的 store 的变量名
}, 2000); //每隔 1 秒
}
};
//-----------------------------------------------------------------------------------------------------------------------------------------------
var reader2 = new Ext.data.JsonReader({
id : 'ID',
root : 'root',
totalProperty : 'totalProperty',
fields : ['ISIP','ISCHLNUM','ISDEVNUM','ISOUTNUM','ISPORT','ISID']
});
var openUrl2 = baseUrl;
openUrl2 += '&methodName=getTIS';
openUrl2 += '¶mCount=2';
// openUrl += '¶m_0=0';
// openUrl += '¶m_1=10';
roleStore2 = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
url : openUrl2
}),
reader : reader2
});
roleStore2.load({
params : {
param_0 : 0,
param_1 : 19
}
});
var bbar2 = new Ext.PagingToolbar({
id:'bb',
pageSize : 19,
store:roleStore2,
storeParams : {
className : 'com.dvision.digitalplatform.bizApp.ttsInfo',
methodName : 'getTIS',
paramCount : '2',
param_0 : '0',
param_1 : '19'
},
paramNames : {
start : 'param_0',
limit : 'param_1'
},
displayInfo : true,
displayMsg : "显示 {0} - {1},共 {2}条",
emptyMsg : '没有数据需要分页',
stripeRows : true,
items : ['-']
});
var sm2 = new Ext.grid.CheckboxSelectionModel({
singleSelect : false
});
var grid2 = new Ext.grid.GridPanel({
id :'grid2',
width: Ext.get('tabs1').getWidth(),
ds : roleStore2,
cm : new Ext.grid.ColumnModel([
sm2,
{
width : 100,
header : '接口ID',
align : 'left',
dataIndex : 'ISID',
sortable:true
},
{
width : 130,
header : '接口IP',
align : 'left',
dataIndex : 'ISIP'
},
{
width : 130,
header : '接口端口',
align : 'left',
dataIndex : 'ISPORT'
},
{
width : 130,
header : '接入设备数量',
align : 'left',
dataIndex : 'ISDEVNUM'
}
,
{
width : 130,
header : '接入通道数量',
align : 'left',
dataIndex : 'ISCHLNUM'
}
,
{
width : 130,
header : '传出码流数量',
align : 'left',
dataIndex : 'ISOUTNUM'
}
]),
sm:sm2,
width : 1345,
height :430,
frame: false,
fill : true,
bbar :bbar2
});
setInterval(function() {
roleStore2.reload(); // dataStore 换成你的 store 的变量名
}, 2000); //每隔 1 秒
//-----------------------------------------------------------------------------------------------------------------------------------------------
var tabs = new Ext.TabPanel({
//renderTo: 'tabs1',
contentEl:'tabs1',
width:1350,
height: 500,
activeTab: 0,
frame:true,
defaults:{autoHeight: true},
deferredRender :false
});
tabs.add({
id:"grid",
title:'转发信息',
layout:'border',
items:[grid]
});
tabs.add({
id:'grid2',
title:'接口信息',
layout:'border',
items:[grid2]
});
tabs.activate(0);
var viewport = new Ext.Viewport({
region:'center',
layout:'fit',
split:true,
collapsible: true,
margins:'0 0 0 0',
frame:true,
items:tabs
});
});
ajaxlistener的servletjava类:
package com.dvision.digitalplatform.ajaxUtil;
import java.io.*;
import java.lang.reflect.Method;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
// Referenced classes of package com.jarp.core:
// Env, Repository
public class AjaxListener extends HttpServlet
{
public static Logger logger;
String className;
String methodName;
ArrayList paramList;
int intParamCount;
static Class class$0; /* synthetic field */
// public void init() throws ServletException
// {
// String repository_DBName = "";
// String repository_DBPoolType = "";
// String repository_DBJNDIName = "";
// String repository_JdbcDriver = "";
// String repository_JdbcURL = "";
// String repository_UserName = "";
// String repository_Password = "";
// int repository_maxConnection = 3;
// BasicConfigurator.configure();
// try
// {
// logger.info("======== AjaxListener initial started (TESTING...) ========");
// repository_DBName = getInitParameter("repository_DBName");
// repository_DBPoolType = getInitParameter("repository_DBPoolType");
// repository_DBJNDIName = getInitParameter("repository_DBJNDIName");
// if(repository_DBName == null)
// repository_DBName = "AjaxListener";
// if(repository_DBName.equals(""))
// repository_DBName = "AjaxListener";
// logger.info("======== repository_DBName == " + repository_DBName + " ========");
// logger.info("======== repository_DBPoolType == " + repository_DBPoolType + " ========");
// if(repository_DBPoolType.equals("Pool"))
// {
// repository_JdbcDriver = getInitParameter("repository_JdbcDriver");
// repository_JdbcURL = getInitParameter("repository_JdbcURL");
// repository_UserName = getInitParameter("repository_UserName");
// repository_Password = getInitParameter("repository_Password");
// repository_maxConnection = (new Integer(getInitParameter("repository_maxConnection"))).intValue();
// ConnectionPools pools = ConnectionPools.getInstance();
// int idx = pools.setPoolParams(repository_DBName, repository_JdbcDriver, repository_JdbcURL, repository_UserName, repository_Password, repository_maxConnection, -1);
// if(pools.createPool(idx))
// {
// logger.info("-------- Repository connection pool created --------");
// }
// logger.info("======== AjaxListener initial finished ========");
// }
// if(repository_DBPoolType.equals("systemPool") && repository_DBJNDIName != null)
// {
// ConnectionPools pools = ConnectionPools.getInstance();
// repository_maxConnection = (new Integer(getInitParameter("repository_maxConnection"))).intValue();
// int idx = pools.setPoolParams(repository_DBName, repository_DBJNDIName, repository_maxConnection, -1);
// if(pools.createPool(idx))
// {
// logger.info("-------- Repository connection pool created --------");
// }
// logger.info("======== AjaxListener initial finished ========");
// }
// }
// catch(Exception ex)
// {
// ex.printStackTrace();
// logger.error("======== AjaxListener initial failed ========");
// }
// }
public AjaxListener()
{
className = "";
methodName = "";
paramList = null;
intParamCount = 0;
}
public void destroy()
{
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/xml;charset=GBK");
request.setCharacterEncoding("GBK");
PrintWriter out = response.getWriter();
String className = "";
String methodName = "";
ArrayList paramList = new ArrayList();
int intParamCount = 0;
className = request.getParameter("className");
methodName = request.getParameter("methodName");
String paramCount = request.getParameter("paramCount");
if(paramCount == null)
paramCount = "0";
intParamCount = Integer.parseInt(paramCount);
paramList = new ArrayList();
for(int i = 0; i < intParamCount; i++)
{
String p = request.getParameter("param_" + i);
paramList.add(p);
}
BufferedReader bufReader = request.getReader();
String strLine = "";
StringBuffer xml = new StringBuffer();
while((strLine = bufReader.readLine()) != null)
xml.append(strLine);
String xmlReturn = doAction(className, methodName, intParamCount, paramList, xml);
out.print(xmlReturn);
out.flush();
out.close();
paramList = null;
xml = null;
}
private String doAction(String className, String methodName, int intParamCount, ArrayList paramList, StringBuffer bufXML)
{
String xmlRet = "";
try
{
Class actionClass = Class.forName(className);
Object actionInstance = actionClass.newInstance();
Object ret = new Object();
int paramCount = intParamCount;
if(bufXML.length() > 0)
paramCount++;
Class params[] = new Class[paramCount];
Object paramValues[] = new Object[paramCount];
for(int i = 0; i < paramCount; i++)
{
params[i] = Class.forName("java.lang.String");
if(bufXML.length() > 0 && i == paramCount - 1)
paramValues[i] = bufXML.toString();
else
paramValues[i] = (String)paramList.get(i);
}
Method m = actionClass.getMethod(methodName, params);
ret = m.invoke(actionInstance, paramValues);
xmlRet = ret.toString();
}
catch(Exception ex)
{
logger.error("className = " + className + "||" + "methodName = " + methodName);
for(int i = 0; i < intParamCount; i++)
logger.error("param_" + i + " = " + (String)paramList.get(i) + "||");
logger.error("doAction's error: " + ex.toString());
ex.printStackTrace();
}
return xmlRet;
}
static
{
logger = Logger.getLogger(com.dvision.digitalplatform.ajaxUtil.AjaxListener.class.getName());
}
}
后台java文件:
package com.dvision.digitalplatform.bizApp.tisInfo;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.sql.DataSource;
import net.sf.json.JSONArray;
import com.dvision.digitalplatform.ajaxUtil.DAO;
import com.dvision.digitalplatform.utils.CollectionUtil;
import com.dvision.digitalplatform.utils.StringUtil;
public class ttsInfo{
public String getTTS(String start, String limit) throws IOException{
DAO dao = new DAO();
Vector v = new Vector();
Vector v2 = new Vector();
HashMap fatherhm = new HashMap();
String rtn = "";
int p1=Integer.parseInt(start);
int p2=p1+Integer.parseInt(limit);
try {
v = dao.execCommand("select count(1) as TSID from T_TSInfo");
if (Integer.parseInt(((Hashtable) v.get(0)).get("TSID").toString()) <= p2)
p2 = Integer.parseInt(((Hashtable) v.get(0)).get("TSID").toString());
v=dao.execCommand("select * from T_TSInfo order by TSID desc");
for(int i=p1;i
v2.add(ht);
}
if(v!=null&&v2!=null){
rtn = "{\"totalProperty\":\"" + v.size() + "\",\"root\":"
+ JSONArray.fromObject(v2).toString() + "}";
}
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println(rtn);
return rtn;
}
public String getTTSIN(String start, String limit,String str) throws IOException{
DAO dao = new DAO();
Vector v = new Vector();
Vector v2 = new Vector();
HashMap fatherhm = new HashMap();
String rtn = "";
int p1=Integer.parseInt(start);
int p2=p1+Integer.parseInt(limit);
int p3=Integer.parseInt(str);
try {
v = dao.execCommand("select count(1) as TSInID from T_TSInInfo where TSID="+p3);
if (Integer.parseInt(((Hashtable) v.get(0)).get("TSINID").toString()) <= p2)
p2 = Integer.parseInt(((Hashtable) v.get(0)).get("TSINID").toString());
v=dao.execCommand("select a.TSInID,a.TSID,a.ISID,b.DeviceName,c.ChannelName from T_TSInInfo a left outer JOIN T_DeviceInfo b on a.DeviceID=b.DeviceID left outer JOIN T_ChannelInfo c on a.ChannelID=c.ChannelID where TSID="+p3+" order by TSInID desc");
for(int i=p1;i
v2.add(ht);
}
if(v!=null&&v2!=null){
rtn = "{\"totalProperty\":\"" + v.size() + "\",\"root\":"
+ JSONArray.fromObject(v2).toString() + "}";
}
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rtn;
}
public String getTIS(String start, String limit) throws IOException{
DAO dao = new DAO();
Vector v = new Vector();
Vector v2 = new Vector();
HashMap fatherhm = new HashMap();
String rtn = "";
int p1=Integer.parseInt(start);
int p2=p1+Integer.parseInt(limit);
try {
v = dao.execCommand("select count(1) as ISID from T_ISInfo");
if(v!=null)
if (Integer.parseInt(((Hashtable) v.get(0)).get("ISID").toString()) <= p2)
p2 = Integer.parseInt(((Hashtable) v.get(0)).get("ISID").toString());
v=dao.execCommand("select * from T_ISInfo order by ISID desc");
for(int i=p1;i
v2.add(ht);
}
if(v!=null&&v2!=null){
rtn = "{\"totalProperty\":\"" + v.size() + "\",\"root\":"
+ JSONArray.fromObject(v2).toString() + "}";
}
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println(rtn);
return rtn;
}
public String getTISOUT(String start, String limit,String str) throws IOException{
DAO dao = new DAO();
Vector v = new Vector();
Vector v2 = new Vector();
HashMap fatherhm = new HashMap();
String rtn = "";
int p1=Integer.parseInt(start);
int p2=p1+Integer.parseInt(limit);
int p3=Integer.parseInt(str);
//System.out.println(str);
try {
v = dao.execCommand("select count(1) as TSOutID from T_TSOutInfo where TSID="+p3);
if (Integer.parseInt(((Hashtable) v.get(0)).get("TSOUTID").toString()) <= p2)
p2 = Integer.parseInt(((Hashtable) v.get(0)).get("TSOUTID").toString());
v=dao.execCommand("select a.TSOutID, a.TSID, a.UserID, a.UserIP, a.UserPort, b.DeviceName,c.ChannelName from T_TSOutInfo a left outer JOIN T_DeviceInfo b on a.DeviceID=b.DeviceID left outer JOIN T_ChannelInfo c on a.ChannelID=c.ChannelID where TSID="+p3+" order by TSOutID desc");
for(int i=p1;i
v2.add(ht);
}
if(v!=null&v2!=null){
rtn = "{\"totalProperty\":\"" + v.size() + "\",\"root\":"
+ JSONArray.fromObject(v2).toString() + "}";
}
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rtn;
}
}
jsp文件:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String roleID = "8";
String url = basePath + "AjaxListener?className=com.dvision.digitalplatform.treeFrame.TreeFrameManage";
url += "&methodName=getTreeFrame";
url += "¶mCount=1";
url += "¶m_0="+roleID;
%>