js 文件注释方法 /** +enter
js中的对象方法 类方法(类似静态方法) 原型方法
- 类方法可直接调用 常用于生成对象 类似后端getInstance
1 | Histogrm.create = function(wnd, container, bname, count) { |
1 | function People(name) |
作业中存在的问题
- 前台url全部小写
- 文档注释
- 方法注释
- 全部封装成对象 而不是部分封装
- dao层要改成getInstands获取实例
- action层 命名 Action+名字
- 异常抛出到action层
- 不要写太多action 通过cmd参数选择执行
- debugger systom.out.println()要去掉
- this.wnd this.doc
- 销毁
- this
- bind绑事件 call aplly
- setOnClick(this.aaa().bind(this));//方法100行 多啦之后套用 bind可以吧this传入
js继承怎么写
页面中调用
1
2
3
4<script>
var bookmain = new bookmain(this.wnd, document.body);
bookmain.dispose();
</script>具体js对象
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192/**
*
* @param wnd
* @param parentElement
* @returns
*/
function bookmain(wnd, parentElement) {
XComponent.call(this, wnd, parentElement);
this._initTestPage();
}
extendClass(bookmain, XComponent, "bookmain");
var list;//列表
/**
* 销毁方法
*/
bookmain.prototype.dispose = function() {
if (this.sp) {
this.sp.dispose();
this.sp = null;
}
if (this.tree) {
this.tree.dispose();
this.tree = null;
}
if (this.his) {
this.his.dispose();
this.his = null;
}
if (this.pageCtrl) {
this.pageCtrl.dispose();
this.pageCtrl = null;
}
if (this.list) {
this.list.dispose();
this.list = null;
}
XComponent.prototype.dispose.call(this);
}
/**
* 初始化方法
*/
bookmain.prototype._initTestPage = function() {
// ----------------------------xsplitter----------------------
var sp = XPanelSplitter.createWithDom(document.getElementById("testdom"));
sp.setFixedPanel(1, 200);
// ----------------------------xtree--------------------------
var tree = new XTree(window, document.getElementById("left-div"), "100%", "100%");
var root = tree.getRootItem();
var map = new Map();
map.put("action", "main");
QueryObj.create("index.do", map, function(query){
try {
query.checkResult();
var res = query.getResponseJSON();
for(var i = 0; i < res.length; i++){
var a = res[i];
var b = a.split(",");
var item = root.appendChild(b[0]);
item.setHasChildren(true);
item.setUserObj({
id : b[1]
});
}
} catch(e) {
hideWaitDialog();
showError(e);
}
});
//节点展开
tree.setOnExpand(function(item){
item.clearChildren();
var params = new Map();
params.put("cid",item.userObj.id);
params.put("action", "tree");
QueryObj.create("index.do", params, function(query){
try {
query.checkResult();
var res = query.getResponseJSON();
for(var i = 0; i < res.length; i++){
//添加子节点
var a = res[i];
var b = a.split(",");
var childitem = item.appendChild(b[0]);
childitem.setUserObj({
id : b[1]
});
}
} catch(e) {
hideWaitDialog();
showError(e);
}
});
});
this._createXtabctrl();
this._createXlist();
//绑定点击事件
tree.setOnClick(function(item, event){
var tid = item.userObj.id;
//alert(tid);
var params = new Map();
params.put("tid",tid);
params.put("action","display");
QueryObj.create("index.do", params, function(query){
try {
query.checkResult();
var res = query.getResponseJSON();
if(document.getElementById("mytable") != null){
var dom1 = document.getElementById("div_count");
var child = document.getElementById("mytable");
dom1.removeChild(child);
//dom1.innerHTML = "";
list.clear();
}
var mytable=document.createElement("table");
mytable.setAttribute("id","mytable");
var row1=mytable.insertRow(-1);
for(var i = 0; i < res.length; i++){
var a = res[i];
var b = a.split(",");
//添加列表
list.addRow(b[0], b[1], b[2], b[3]);
if( i == 0){
var bname = b[0];
var count = b[4];
var cell=row1.insertCell(-1);
var his=new Histogrm(window,cell,bname,count);
}else if(res[i].split(",")[0] != res[i-1].split(",")[0]){
var bname = b[0];
var count = b[4];
var cell = row1.insertCell(-1);
var his = new Histogrm(window,cell,bname,count);
}
}
div_count.appendChild(mytable);
} catch(e) {
hideWaitDialog();
showError(e);
}
});
});
}
/**
* 构建页面选择按钮
*/
bookmain.prototype._createXtabctrl = function() {
//右表显示
var pageCtrl = new XPageControl(window, document.getElementById("right-div"));
//列表
var div_table = document.createElement("div");
div_table.setAttribute("id","div_table");
pageCtrl.addPage(I18N.getString("test.web.study.test.ftl.jyjl","借阅记录"), "").appendChild(div_table);
//图形
var div_count = document.createElement("div");
div_count.setAttribute("id","div_count");
pageCtrl.addPage(I18N.getString("test.web.study.test.ftl.tjfx","统计分析"), "").appendChild(div_count);
pageCtrl.setActive(0);
}
/**
* 构建列表
*
*/
bookmain.prototype._createXlist = function() {
var columns = [["书名", "25%"], ["借阅人", "25%"], ["借阅时间", "25%"], ["归还时间", "25%"]];
list = new XList(window,document.getElementById("div_table"),"100%","100%");
list.enableThreeState(true);
list.setSortable(true);
list.setMouseOver(true);
list.setTextSelected(false);
list.setDraggable(true);
list.setDropable(true);
list.setColorEvenRows(true);
list.setAllTextCell(false);
list.initWithColumns(columns);
}
1 | function splitter(wnd, parentElement) { |
1 | /** |
1 | /** |
1 | function Histogrm(wnd, container, bname, count) { |
- 自己吧上面的修改
1 | function bookmain(wnd, parentElement) { |
1 | package com.esen.gxdc.util; |
1 | package com.esen.gxdc.test; |