循环提交上下文
我在使用以下代码时遇到问题:
<t:form t:id="locationsForm" t:zone="myZone">
<t:loop t:source="locations" t:value="location" t:encoder="locationEncoder">
<t:textfield t:value="location.name" />
<t:submit t:event="RemoveLocation" t:value="remove ${location.hashCode()}" t:context="${location.hashCode()}" />
</t:loop>
<t:submit t:value="save" />
</t:form>
假设我最终得到以下按钮:
<input type="submit" name="button" id="button" value="remove 12339020">
<input type="submit" name="button" id="button" value="remove 2504658">
单击任一按钮都只会触发上下文 2504658
的事件 onRemoveLocation
。
我猜测第二个提交组件正在覆盖第一个提交组件注册的事件处理程序,因此它们最终都会调用第二个组件的事件处理程序。
我尝试将 clientId
设置为唯一的值,但这没有帮助。
我需要删除按钮来提交相同的表单,因为用户可以在同一操作中更新一个元素的名称并删除第二个元素。
感谢建议,p。
(挂毯5.1.0.5)
I'm having a problem with the following code:
<t:form t:id="locationsForm" t:zone="myZone">
<t:loop t:source="locations" t:value="location" t:encoder="locationEncoder">
<t:textfield t:value="location.name" />
<t:submit t:event="RemoveLocation" t:value="remove ${location.hashCode()}" t:context="${location.hashCode()}" />
</t:loop>
<t:submit t:value="save" />
</t:form>
Say I end up with the following buttons:
<input type="submit" name="button" id="button" value="remove 12339020">
<input type="submit" name="button" id="button" value="remove 2504658">
Clicking on either button will only ever trigger the event onRemoveLocation
with the context 2504658
.
I'm guessing the second submit component is overriding the event handler registered by the first, so they both end up calling the second components event handler.
I have tried setting the clientId
to something unique but that did not help.
I need the remove buttons to submit the same form since the user may update the name of one element and remove the second in the same operation.
Advice appreciated, p.
(Tapestry 5.1.0.5)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在具有上下文的循环内使用
Submit
时,您还需要设置defer="false"
以避免此行为:从 文档:
When using
Submit
inside a loop with a context, you'll also need to setdefer="false"
to avoid this behavior:From the docs: