代码之家  ›  专栏  ›  技术社区  ›  ponzao

在tapestry5中更新窗体内的区域

  •  4
  • ponzao  · 技术社区  · 15 年前

    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>
    

    有没有一种方法来进行绑定?如果没有,还有什么其他的替代方法?

    1 回复  |  直到 12 年前
        1
  •  4
  •   Community CDub    4 年前

    这个答案已经过时了,您可以使用常用的区域功能添加表单元素 from Tapestry 5.2 on

    原始答案,对Tapestry 5.0和5.1有效:

    这个 FormInjector 组件允许您将窗体元素添加到现有窗体。不过,您必须编写一些自定义JS来触发表单注入。

    在TML中:

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

    $('theClientIdOfMyFormInjector').trigger();
    

    您可以通过其类名在窗体中找到injector DIV( myForm.down('div.t-forminjector')

    组件类:

    @Inject
    private Block formFieldsBlock;
    
    @OnEvent(component = "injector")
    Block loadExtraFormFields() {
        return this.formFieldsBlock;
    }