Updating a zone inside a form in Tapestry 5

纵然是瞬间 提交于 2019-11-30 22:16:53

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:

<div t:type="FormInjector" t:id="injector" position="below" />

You can trigger the injection in your JS code like this:

$('theClientIdOfMyFormInjector').trigger();

You can find the injector DIV inside your form by its class name (myForm.down('div.t-forminjector')).

The component class:

@Inject
private Block formFieldsBlock;

@OnEvent(component = "injector")
Block loadExtraFormFields() {
    return this.formFieldsBlock;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!