Skip to content

Commit 24f5a0c

Browse files
author
Michael Zhou
committed
添加关于screen-event-adapter的示例
1 parent 88670f4 commit 24f5a0c

File tree

3 files changed

+103
-11
lines changed

3 files changed

+103
-11
lines changed

archetype-webx-quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
name="webx-simple">
66
<requiredProperties>
77
<requiredProperty key="webx-version">
8-
<defaultValue>3.1.0</defaultValue>
8+
<defaultValue>3.1.1</defaultValue>
99
</requiredProperty>
1010
<requiredProperty key="spring-version">
1111
<defaultValue>3.1.1.RELEASE</defaultValue>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2002-2012 Alibaba Group Holding Limited.
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package ${package}.app1.module.screen;
19+
20+
import java.io.IOException;
21+
import javax.servlet.http.HttpServletResponse;
22+
23+
import org.springframework.beans.factory.annotation.Autowired;
24+
25+
/**
26+
* 这个例子演示了用一个screen类处理多个事件的方法。
27+
*
28+
* @author Michael Zhou
29+
*/
30+
public class SayHelloInLanguage {
31+
@Autowired
32+
private HttpServletResponse response;
33+
34+
/** 此方法会在所有的event handler之前执行。 */
35+
public void beforeExecution() {
36+
response.setContentType("text/plain");
37+
}
38+
39+
/** 此方法会在所有的event handler之后执行。 */
40+
public void afterExecution() throws IOException {
41+
response.flushBuffer(); // 此调用并非必须,只是用来演示afterExecution方法而已
42+
}
43+
44+
/** 默认语言:英文 */
45+
public void doPerform() throws IOException {
46+
doEnglish();
47+
}
48+
49+
/** 英文 */
50+
public void doEnglish() throws IOException {
51+
response.getWriter().println("English: Hello");
52+
}
53+
54+
/** 中文 */
55+
public void doChinese() throws IOException {
56+
response.getWriter().println("Chinese: 你好");
57+
}
58+
59+
/** 法语 */
60+
public void doFrench() throws IOException {
61+
response.getWriter().println("French: Bonjour");
62+
}
63+
64+
/** 西班牙语 */
65+
public void doSpanish() throws IOException {
66+
response.getWriter().println("Spanish: Hola");
67+
}
68+
}
69+

archetype-webx-quickstart/src/main/resources/archetype-resources/src/main/webapp/app1/templates/screen/index.vm

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,43 @@ $page.setTitle("It works.")
3939
</li>
4040

4141
<li>
42-
<h2>Screen with Multiple Templates</h2>
42+
<h2>Single Screen for Multiple Templates</h2>
4343

4444
<ul>
45-
<li>#set($url = "$app1Link.setTarget('list/as_html.htm')")
46-
<a href="$url">Show as HTML: $url</a>
47-
</li>
45+
<li>#set($url = "$app1Link.setTarget('list/as_html.htm')")
46+
<a href="$url">Show as HTML: $url</a>
47+
</li>
4848

49-
<li>#set($url = "$app1Link.setTarget('list/as_xml.htm')")
50-
<a href="$url">Show as XML: $url</a>
51-
</li>
49+
<li>#set($url = "$app1Link.setTarget('list/as_xml.htm')")
50+
<a href="$url">Show as XML: $url</a>
51+
</li>
5252

53-
<li>#set($url = "$app1Link.setTarget('list/as_json.htm')")
54-
<a href="$url">Show as JSON: $url</a>
55-
</li>
53+
<li>#set($url = "$app1Link.setTarget('list/as_json.htm')")
54+
<a href="$url">Show as JSON: $url</a>
55+
</li>
5656
</ul>
5757
</li>
58+
59+
<li>
60+
<h2>Single Screen with Multiple Event Handlers</h2>
61+
62+
<ul>
63+
<li>#set($url = "$app1Link.setTarget('say_hello_in_language.do')")
64+
<a href="$url">$url</a>
65+
</li>
66+
67+
<li>#set($url = "$app1Link.setTarget('say_hello_in_language/chinese.do')")
68+
<a href="$url">$url</a>
69+
</li>
70+
71+
<li>#set($url = "$app1Link.setTarget('say_hello_in_language/french.do')")
72+
<a href="$url">$url</a>
73+
</li>
74+
75+
<li>#set($url = "$app1Link.setTarget('say_hello_in_language/spanish.do')")
76+
<a href="$url">$url</a>
77+
</li>
78+
</ul>
79+
</li>
80+
5881
</ol>

0 commit comments

Comments
 (0)