Form
描述
管理HTML<form>的组件,其他相关组件必须被包含在组建内部。
当表单被提交时,Form组件会等待所有的内部组件显示。当Form组件显示时(在显示周期,生成HTML显示),更新属性值和调用他们的监听器。另外:每一个组件并不单单用来显示HTML的责任(来显示fotm),还处理它的表单提交。只有这些完毕后才Form组件才通知它的监听器。
名称 |
类型 |
方向 |
必须 |
默认 |
描述 |
listener |
IActionListener |
in |
no |
|
处理请求 |
delegate |
IValidationDelegate |
in |
no |
|
用来处理堆栈错误和报告的对象。单个实例共享给所有的ValidField和FieldLable组件在单个form中 |
parameters |
Object or Object[] or List |
in |
no |
|
An array of Objects to be encoded into the URL. These parameters will be decoded when the link is triggered. |
stateful |
boolean |
in |
no |
true |
如果是ture,组件被出发时需要一个活动的HttpSession,如果没有会抛出StateLinkException异常。如果是false则没有必要检查。必要状态的附加在URL上。 |
direct |
boolean |
in |
no |
true |
默认调用direct服务,这样减少处理请求的数量 |
method |
String |
in |
no |
POST |
Tag<form>的method参数值 |
例子
Home.html
1
<html>
2
<head>
3
<title>Tutorial: HelloWorld</title>
4
</head>
5
<body jwcid="@Body">
6
<h1>HelloWorld Tutorial</h1>
7
8
<form jwcid="@Form" listener="ognl:listeners.formSubmit">
9
EnterYourName
10
<br/>
11
<input jwcid="enterYourName" name="textfield" type="text"/>
12
<br/>
13
<input type="submit" value="Submit"/>
14
<br/>
15
</form>
16
17
<span jwcid="@Insert" value="ognl:yourName"/>
18
19
</body>
20
</html>
21
Home.page
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE page-specification
3
PUBLIC "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
4
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
5
<!-- generated by Spindle, http://spindle.sourceforge.net -->
6
7
<page-specification class="com.Home">
8
9
<description>Hello World Home Page</description>
10
11
12
<property-specification name="yourName" type="java.lang.String" persistent="yes"/>
13
<component id="enterYourName" type="TextField">
14
<static-binding name="displayName">displayName</static-binding>
15
<binding name="value" expression="yourName"/>
16
</component>
17
18
</page-specification>
19
20
Home.java
1
package com;
2
3
import org.apache.tapestry.IRequestCycle;
4
import org.apache.tapestry.html.BasePage;
5
6
public abstract class Home extends BasePage
{
7
public abstract String getYourName();
8
9
public static void main(String args[])
{
10
11
}
12
13
public void formSubmit(IRequestCycle cycle)
{
14
// Process the form submission.
15
}
16
}
17