macros.vm
8.75 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#** -------------------------------------------
* 显示所有headers
* -------------------------------------------- *#
#macro (showHead $defaultTitle)
#showTitle ($defaultTitle)
#showMetaTags ()
#showHttpEquiv ()
#showStylesheets ()
#showJavascripts ()
#end
#** -------------------------------------------
* 显示标题,如果未提供标题,则使用默认值
* -------------------------------------------- *#
#macro (showTitle $defaultTitle)
#if( $page.title != "" )
<title>$page.message("web_site_name") - $page.title</title>
#else
<title>$!defaultTitle</title>
#end
#end
#** -------------------------------------------
* 显示meta tags
* -------------------------------------------- *#
#macro (showMetaTags)
#foreach($metaTag in $page.metaTags.keySet())
<meta name="$metaTag" content="$page.metaTags.get($metaTag)">
#end
#end
#** -------------------------------------------
* 显示meta http-equiv
* -------------------------------------------- *#
#macro (showHttpEquiv)
#foreach($httpEquiv in $page.httpEquivs.keySet())
<meta http-equiv="$httpEquiv" content="$page.httpEquivs.get($httpEquiv)">
#end
#end
#** -------------------------------------------
* 显示stylesheets
* -------------------------------------------- *#
#macro (showStylesheets)
#foreach( $styleSheet in $page.styleSheets )
<link rel="stylesheet" href="$styleSheet.Url"
#if($styleSheet.Type != "" ) type="$styleSheet.Type" #end
#if($styleSheet.Media != "") media="$styleSheet.Media" #end
#if($styleSheet.Title != "") title="$styleSheet.Title" #end>
#end
#end
#** -------------------------------------------
* 显示javascripts
* -------------------------------------------- *#
#macro (showJavascripts)
#foreach( $script in $page.scripts )
<script type="text/javascript" src="$script" language="JavaScript"></script>
#end
#end
#** -------------------------------------------
* 显示body attributes
* -------------------------------------------- *#
#macro (bodyAttributes)
#foreach( $attributeName in $page.bodyAttributes.keySet() )
$attributeName="$page.bodyAttributes.get($attributeName)"
#end
#end
#** -------------------------------------------
* 显示radio
* -------------------------------------------- *#
#macro (radio $name $property $value)
<input type="radio" name=$name value="$value" #if ($property==$value) checked #end/>
#end
#** -------------------------------------------
* 文本信息显示
* @param $text 要显示的内容
* @param $msgStyle 指定css样式
* -------------------------------------------- *#
#macro (showMessage $text $msgStyle)
#if($text)<div class=$msgStyle>$!text</div>#end
#end
#** -------------------------------------------
* 表单验证信息显示
* @param $text 要显示的内容
* @param $msgStyle 指定css样式
* -------------------------------------------- *#
#macro (formValidation $msg $default)
#if($msg)
<span class="errorMessage">$!msg</span>
#elseif($default)
<span class="small">$!default</span>
#end
#end
#** -------------------------------------------
* 表单验证信息必填项标识
* -------------------------------------------- *#
#macro (requiredFiled)
<span style="color:red;">(*)</span>
#end
#** -------------------------------------------
* td内容部分显示,当鼠标移到上面显示全部
* @param $field 要显示的内容
* @param $width 显示的宽度
* -------------------------------------------- *#
#macro (ellipsis $field $width)
<span>$stringUtil.substring($field, 0 ,$width)#if($field.length() > $width)...#end</span>
#end
#** -------------------------------------------
* 显示select box
* @param $name select name
* @param $map select option map
* @param $selected selected value
* @param $hint int value
* @param $attributes
* -------------------------------------------- *#
#macro (select $name $map $selected $hint $attributes)
#set ($_map = $map)
#set ($_selected = $selected)
#set ($_attributes = $stringUtil.split($attributes,";"))
<select name="$name" #foreach($_attr in $_attributes) $_attr#end>
#if ($hint != "")
<option value="">$hint</option>
#end
#foreach ($_key in $_map.keySet())
<option value="$_key" #if ($_key == $_selected) selected #end>$_map.get($_key)</option>
#end
</select>
#end
#** -------------------------------------------
* 显示级联select box,目前支持两级
* @param $name select name
* @param $map select option map
* @param $selected selected value
* @param $hint int value
* @param $attributes
* -------------------------------------------- *#
#macro (cascadeSelect $name $name2 $json $selected $hint $attributes)
#set ($_id = $stringUtil.replace($name, '.', '_'))
#set ($_id2 = $stringUtil.replace($name2, '.', '_'))
#set ($_selected = $selected)
#set ($_attributes = $stringUtil.split($attributes,";"))
<select id="$_id" name="$name" #foreach($_attr in $_attributes) $_attr#end>
</select>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#$_id').selectLink('#$_id2', eval('$json'), '$!selected', '$!hint');
});
</script>
#end
#** -------------------------------------------
* 显示check box
* @param $name checkbox name
* @param $map checkbox
* @param $checkedList
* @param $class
* -------------------------------------------- *#
#macro (checkbox $name $map $checkedList $class)
#set ($_map = $map)
#set ($_checked = $checkedList)
#foreach ($_key in $_map.keySet())
#set ($_value = $_key + "----" + $_map.get($_key))
<span #if($class)class="$!class"#end>
<input type="checkbox" name="$!name" value="$_value" #foreach($_tmp in $_checked)#if($_key == $_tmp) checked #end#end/>
<label>$_map.get($_key)</label>
</span>
#end
#end
#** -------------------------------------------
* 显示分页信息
* -------------------------------------------- *#
#macro (pagination)
<div class="pagination"></div>
<input type="hidden" value="$total" name="num_entries" id="num_entries" class="numeric"/>
<input type="hidden" value="#if(!$currentPage)0#else$currentPage#end" name="current_page" id="current_page" class="numeric"/>
<input type="hidden" value="$request.getRequestURI()?$request.getQueryString()" name="link_to" id="link_to" class="numeric"/>
<input type="hidden" value="3" name="items_per_page" id="items_per_page" class="numeric"/>
<input type="hidden" value="10" name="num_display_entries" id="num_display_entries" class="numeric"/>
<input type="hidden" value="2" name="num_edge_entries" id="num_edge_entries" class="numeric"/>
<input type="hidden" value="上一页" name="prev_text" id="prev_text" class="numeric"/>
<input type="hidden" value="下一页" name="next_text" id="next_text" class="numeric"/>
#end
#** -------------------------------------------
* 多文件上传
* @param $action 指定请求提交的后台程序(必须通过该参数接收文件数据:MultipartFile fileData)
* @param $param 以post方式传递的参数,必须是json格式的
* @param $fileExt 上传文件的扩展名,启用本项时需同时声明fileDesc
* @param $fileDesc 出现在上传对话框中的文件类型描述
* @param $sizeLimit 控制上传文件的大小,单位byte
* -------------------------------------------- *#
#macro (multiFileUpload $action $param $fileExt $fileDesc $sizeLimit)
<link href="$uribroker.styles.setTarget("uploadify.css")" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="$page.url("/scripts/swfobject.js")"></script>
<script type="text/javascript" src="$page.url("/scripts/jquery.uploadify.v2.1.0.min.js")"></script>
<script type="text/javascript" src="$page.url("/scripts/zeus-multifileupload.js")"></script>
<input type="hidden" name="uploader" value='$uribroker.flash.setTarget("uploadify.swf")' class="uploadify"/>
<input type="hidden" name="cancelImg" value='$uribroker.images.setTarget("cancel.png")' class="uploadify"/>
<input type="hidden" name="script" value='$action' class="uploadify"/>
<input type="hidden" name="scriptData" value="$param" class="uploadify"/>
<input type="hidden" name="fileExt" value="$fileExt" class="uploadify"/>
<input type="hidden" name="fileDesc" value="$fileDesc" class="uploadify"/>
<input type="hidden" name="sizeLimit" value="$sizeLimit" class="uploadify"/>
<input type="hidden" id="successMsg" value='$page.message("100001")'/>
<input type="hidden" id="failureMsg" value='$page.message("100002")'/>
<div id="fileQueue"></div>
<input type="file" name="uploadify" id="uploadify"/>
<p><a href="javascript:jQuery('#uploadify').uploadifyUpload()">上传文件</a> | <a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">取消上传队列</a> | <a href='$uribroker.shopDetail?sId=$request.getParameter("sId")'>确定</a></p>
#end