这个答案已经过时,您可以使用 Tapestry
5.2上的常规区域功能添加表单元素。不过,此方法仍然可以正常使用。
原始答案,对于Tapestry 5.0和5.1有效:
该
FormInjector组件允许您将表单元素添加到现有表单中。不过,您将必须编写一些自定义JS来触发表单注入。
在您的TML中:
<div t:type="FormInjector" t:id="injector" position="below" />
您可以像这样在JS代码中触发注入:
$('theClientIdOfMyFormInjector').trigger();您可以在表单内通过其类名(
myForm.down('div.t-forminjector'))找到注射器DIV 。组件类:
@Injectprivate Block formFieldsBlock;@onEvent(component = "injector")Block loadExtraFormFields() { return this.formFieldsBlock;}


