Start.html
Start.properties:
Start.java
小结:
1.用Start.properties来显示非英文字符,在HTML模板中使用表达式${message:*}, *是在properties中定义。
2.Action的事件驱动有二种方式:一是使用annotation @OnEvent(component="select"),然后任意定义一个方法名,如上可以为:void chose(int index);二是按照默认规则定义方法名,以on+动作名称+From+组件ID名,如上动作为Action,组件ID为select(<t:comp id="select" context="prop:index" type="ActionLink">中的id),则方法名为:onActionFromSelect(int index)。
3.Action是默认的事件类型,如果页面中有其他事件类型,则需要声明value值,如:@OnEvent(value="action",component="select")
4.Loop组件包含了之前Count组件,现在核心组件中已无Count组件。</t:comp>
- <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>${message:page-title}</title>
- <body>
- <p>
- <t:Loop source="prop:1..10" value="prop:index">
- <a t:type="ActionLink" t:id="select" t:context="prop:index">${index}a> --
- </t:Loop>
- <p>
- <t:If test="selected">
- you selected: <strong>${selected}</strong>
- </t:If>
- </p>
- </body>
- </html>
Start.properties:
文本 代码
- page-title=中文标题
Start.java
java 代码
- package org.examples.pages;
- //import org.apache.tapestry.annotations.OnEvent;
- import org.apache.tapestry.annotations.Persist;
- public class Start {
-
- private int _index;
- @Persist
- private int _selected;
- public int getIndex(){
- return _index;
- }
- public void setIndex(int index){
- _index = index;
- }
- public int getSelected(){
- return _selected;
- }
- public void setSelected(int selected){
- _selected = selected;
- }
- //@OnEvent(component="select")
- void onActionFromSelect(int index){
- _selected = index;
- }
- }
小结:
1.用Start.properties来显示非英文字符,在HTML模板中使用表达式${message:*}, *是在properties中定义。
2.Action的事件驱动有二种方式:一是使用annotation @OnEvent(component="select"),然后任意定义一个方法名,如上可以为:void chose(int index);二是按照默认规则定义方法名,以on+动作名称+From+组件ID名,如上动作为Action,组件ID为select(<t:comp id="select" context="prop:index" type="ActionLink">中的id),则方法名为:onActionFromSelect(int index)。
3.Action是默认的事件类型,如果页面中有其他事件类型,则需要声明value值,如:@OnEvent(value="action",component="select")
4.Loop组件包含了之前Count组件,现在核心组件中已无Count组件。</t:comp>