0c7370274c0d553f7b8fe6549ac39464d43d225f.svn-base
7.09 KB
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
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>代码模板管理</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
$(document).ready(function() {
$("#name").focus();
$("#inputForm").validate({
submitHandler: function(form){
loading('正在提交,请稍等...');
form.submit();
},
errorContainer: "#messageBox",
errorPlacement: function(error, element) {
$("#messageBox").text("输入有误,请先更正。");
if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
error.appendTo(element.parent().parent());
} else {
error.insertAfter(element);
}
}
});
});
</script>
</head>
<body>
<ul class="nav nav-tabs">
<li><a href="${ctx}/gen/genTemplate/">代码模板列表</a></li>
<li class="active"><a href="${ctx}/gen/genTemplate/form?id=${genTemplate.id}">代码模板<shiro:hasPermission name="gen:genTemplate:edit">${not empty genTemplate.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="gen:genTemplate:edit">查看</shiro:lacksPermission></a></li>
</ul><br/>
<form:form id="inputForm" modelAttribute="genTemplate" action="${ctx}/gen/genTemplate/save" method="post" class="form-horizontal">
<form:hidden path="id"/>
<sys:message content="${message}"/>
<div class="control-group">
<label class="control-label">名称:</label>
<div class="controls">
<form:input path="name" htmlEscape="false" maxlength="200" class="required"/>
</div>
</div>
<div class="control-group">
<label class="control-label">归属分类:</label>
<div class="controls"><%--
<form:select path="category" class="required">
<form:option value=""></form:option>
<form:options items="${fns:getDictList('gen_category')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:select> --%>
<form:checkboxes items="${fns:getDictList('gen_category')}" path="categoryList" itemLabel="label" itemValue="value" htmlEscape="false"/>
</div>
</div>
<div class="control-group">
<label class="control-label">生成路径:</label>
<div class="controls">
<form:input path="filePath" htmlEscape="false" maxlength="500" class="required input-xxlarge"/>
<br/>
<span class="help-inline">
示例如下:<br/>
java:src/main/java/\${packageName}/\${moduleName}/entity/\${subModuleName}<br/>
view:src/main/webapp/WEB-INF/views/\${lastPackageName}/${moduleName}/\${subModuleName}<br/>
mapper:/src/main/resources/mappings/\${dbType}/\${lastPackageName}/\${moduleName}/\${subModuleName}
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">生成文件名:</label>
<div class="controls">
<form:input path="fileName" htmlEscape="false" maxlength="500" class="required input-xlarge"/>
<br/>
<span class="help-inline">
示例如下:<br/>
java:\${ClassName}Entity.jsp<br/>
view:\${className}List.jsp
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">内容:</label>
<div class="controls">
<form:textarea id="content" htmlEscape="true" path="content" rows="25" class="required" style="width:90%;" wrap="off" />
<script type="text/javascript">
/*------selection operations-------*/
function insertAtCursor(obj, txt) {
obj.focus();
//IE support
if (document.selection) {
sel = document.selection.createRange();
sel.text = txt;
}
//MOZILLA/NETSCAPE support
else {
var startPos = obj.selectionStart;
var scrollTop = obj.scrollTop;
var endPos = obj.selectionEnd;
obj.value = obj.value.substring(0, startPos) + txt + obj.value.substring(endPos, obj.value.length);
startPos += txt.length;
obj.setSelectionRange(startPos, startPos);
obj.scrollTop = scrollTop;
}
}
function getCaretPos(ctrl) {
var caretPos = 0;
if (document.selection) {
// IE Support
var range = document.selection.createRange();
// We'll use this as a 'dummy'
var stored_range = range.duplicate();
// Select all text
stored_range.moveToElementText(ctrl);
// Now move 'dummy' end point to end point of original range
stored_range.setEndPoint('EndToEnd', range);
// Now we can calculate start and end points
ctrl.selectionStart = stored_range.text.length - range.text.length;
ctrl.selectionEnd = ctrl.selectionStart + range.text.length;
caretPos = ctrl.selectionStart;
} else if (ctrl.selectionStart || ctrl.selectionStart == '0')
// Firefox support
caretPos = ctrl.selectionStart;
return (caretPos);
}
function getCurrentLineBlanks(obj) {
var pos = getCaretPos(obj);
var str = obj.value;
var i = pos - 1;
while (i >= 0) {
if (str.charAt(i) == '\n')
break;
i--;
}
i++;
var blanks = "";
while (i < str.length) {
var c = str.charAt(i);
if (c == ' ' || c == '\t')
blanks += c;
else
break;
i++;
}
return blanks;
}
/* set all the tab indent for all the text areas */
$("textarea").each(function() {
$(this).keydown(function(eve) {
if (eve.target != this) return;
if (eve.keyCode == 13)
last_blanks = getCurrentLineBlanks(this);
else if (eve.keyCode == 9) {
eve.preventDefault();
insertAtCursor(this, "\t");
this.returnValue = false;
}
}).keyup(function(eve) {
if (eve.target == this && eve.keyCode == 13)
insertAtCursor(this, last_blanks);
});
});
</script>
</div>
</div>
<div class="control-group">
<label class="control-label">备注:</label>
<div class="controls">
<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="200" class="input-xxlarge"/>
</div>
</div>
<div class="form-actions">
<shiro:hasPermission name="gen:genTemplate:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/> </shiro:hasPermission>
<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
</div>
</form:form>
</body>
</html>