在 Tapestry 5 中更新表单内的区域
我在 Form
中有一个 Zone
,该 Zone
使用包含我想绑定到父级的输入字段的块进行更新表单
。不幸的是,这似乎并不像我希望的那么容易,因为我收到了以下错误消息。
The Description component must be enclosed by a Form component. [at classpath:...Page.tml, line 100]
下面是源 .tml
的简化版本。
<t:form t:id="editForm" t:context="item.id">
<table>
<tr>
<th>Name</th>
<td><t:textField value="item.name"/></td>
</tr>
<t:block t:id="block">
<tr class="person">
<th>Description</th>
<td><t:textField t:id="description" value="item.description"/></td>
</tr>
</t:block>
<t:zone t:id="itemZone" id="itemZone"/>
<t:actionlink t:id="item" zone="itemZone">Click me!</t:actionlink>
</table>
</t:form>
有没有办法进行绑定,如果没有,还有其他替代方法吗?
I've got a Zone
inside a Form
, the Zone
is updated with a block containing input fields which I would like to bind to the parent Form
. Unfortunately this doesn't seem to work quite as easily as I hoped as I am greeted with the following error message.
The Description component must be enclosed by a Form component. [at classpath:...Page.tml, line 100]
A simplified version of the source .tml
is below.
<t:form t:id="editForm" t:context="item.id">
<table>
<tr>
<th>Name</th>
<td><t:textField value="item.name"/></td>
</tr>
<t:block t:id="block">
<tr class="person">
<th>Description</th>
<td><t:textField t:id="description" value="item.description"/></td>
</tr>
</t:block>
<t:zone t:id="itemZone" id="itemZone"/>
<t:actionlink t:id="item" zone="itemZone">Click me!</t:actionlink>
</table>
</t:form>
Is there a way to do the binding and if not what other alternatives are there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个答案已经过时了,您可以使用来自 Tapestry 的常用区域功能添加表单元素 5.2 上。不过,此方法仍然有效。
原始答案,对 Tapestry 5.0 和 5.1 有效:
FormInjector
组件允许您将表单元素添加到现有表单中。不过,您必须编写一些自定义 JS 来触发表单注入。在 TML 中:
您可以像这样在 JS 代码中触发注入:
您可以通过类名在表单中找到注入器 DIV (
myForm.down('div.t-forminjector')
) 。组件类:
This answer is outdated, you can add form elements using the usual zone functionality from Tapestry 5.2 on. This method still works as well, though.
Original answer, valid for Tapestry 5.0 and 5.1:
The
FormInjector
component allows you to add form elements to an exising form. You will have to write some custom JS to trigger the form injection, though.In your TML:
You can trigger the injection in your JS code like this:
You can find the injector DIV inside your form by its class name (
myForm.down('div.t-forminjector')
).The component class: