5

Zone親にバインドしたい入力フィールドを含むブロックで更新さFormれます。残念ながら、これは期待したほど簡単には機能しないようで、次のエラー メッセージが表示されます。ZoneForm

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>

バインディングを行う方法はありますか?そうでない場合、他にどのような選択肢がありますか?

4

1 に答える 1

4

この回答は時代遅れです。Tapestry 5.2の通常のゾーン機能を使用してフォーム要素を追加できます。ただし、この方法は引き続き機能します。

Tapestry 5.0および5.1に有効な元の回答:

コンポーネントを使用すると、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;
}
于 2010-06-03T18:03:04.307 に答える