我有一个Zone
里面一个Form
, the Zone
已更新为包含我想绑定到父级的输入字段的块Form
。不幸的是,这似乎并不像我希望的那么容易,因为我收到了以下错误消息。
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>
有没有办法进行绑定,如果没有,还有其他替代方法吗?
这个答案已经过时了,您可以使用常用的区域功能添加表单元素从 Tapestry 5.2 开始。不过,这种方法仍然有效。
原始答案,适用于 Tapestry 5.0 和 5.1:
The FormInjector组件允许您将表单元素添加到现有表单。不过,您必须编写一些自定义 JS 来触发表单注入。
在您的 TML 中:
<div t:type="FormInjector" t:id="injector" position="below" />
您可以像这样在 JS 代码中触发注入:
$('theClientIdOfMyFormInjector').trigger();
您可以通过类名在表单中找到注入器 DIV(myForm.down('div.t-forminjector')
).
组件类:
@Inject
private Block formFieldsBlock;
@OnEvent(component = "injector")
Block loadExtraFormFields() {
return this.formFieldsBlock;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)