自动完成程序不提交表单值
我正在使用 struts 2 和 jquery 插件。
我有一个 jsp,其中定义了两个元素:一个选择和一个自动完成器。 我需要过滤从先前选择的提供程序中选择的产品:
<s:form id='myForm'>
<s:select list="providers" value="provider.id" listKey="id" name="provider.id"/>
<sj:autocompleter
id="productId"
name="productDescription"
value="%{productDescription}"
listenTopics="providerChanged"
href="%{url_products}"
formIds="myForm"
/>
问题是自动完成程序在输入时不会在 sj:select 中提交最新选定的值。因此,当调用 url_products 时,provider.id 的旧值将发送到操作。
请注意,我在自动完成程序中添加了 formId,但没有解决问题。
有什么想法吗???
I'm working with struts 2 and jquery plugin.
I have a jsp where I have defined two elements, a select and an autocompleter.
I need to filter the products selected from the provider previously selected:
<s:form id='myForm'>
<s:select list="providers" value="provider.id" listKey="id" name="provider.id"/>
<sj:autocompleter
id="productId"
name="productDescription"
value="%{productDescription}"
listenTopics="providerChanged"
href="%{url_products}"
formIds="myForm"
/>
The problem is that the autocompleter does not submit the latest selected values in the sj:select while typing in it. So when url_products is called, an old value for the provider.id is sent to the action.
Plese note that I added formIds in the autocompleter but does not resolve the problem.
Any ideas???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有在 JS 中添加任何代码,因此我包含了一些其他相关代码,可以更好地描述我所实现的内容:
操作中的代码:
jsp 处的 URL:
struts.xml:
I did not add any code at JS, so I include some other code related that can describe better what I've implemented:
Code in the action:
URL at jsp:
struts.xml:
我最近玩过 sj:autocompleter 并遇到了非常相似的问题。我不确定这是不是我在后端搞砸了 - 我想自动完成器来匹配最后输入的项目:
这个和那个以及其他东西..
我仍然想匹配“某些东西”但不覆盖'这个和那个以及'如果选择了'某事' - 无论如何,为了说明这一点,不是我的拼接和切割导致了错误,而是添加了一个简单的修复
: sj:自动完成器。默认情况下,如果省略该值,则该值为 true。
尝试一下,看看它是否适合你
I've played around with sj:autocompleter lately and had a very similar problem. I wasn't sure if it was my messing around on the back end doing that - I wanted to autocompleter to match on the last item being typed:
This and that and someth..
I still wanted to match on 'something' but without overwriting 'This and that and ' if 'something' was selected - anyway, to get to the point, it wasn't my splicing and dicing that caused the error it was a simple fix of adding:
to the sj:autocompleter. By default, this value is true if you omit it.
Try it and see if it works for you