如何在Struts2中为选择(选择事件)提供单独的操作(在自动完成文本框中使用) [英] How to give seperate action for selections(select event) in Struts2 (used in an autocompletion text box)
问题描述
我有一个从DB启用自动完成功能的文本框.我正在使用Javascript启用自动完成功能.
I have an text box which is autocomplete enabled from DB.I'm using Javascript to enable autocomplete functionality.
$("#loanApplicationNo").autocomplete("<s:url action="/suggestByLoanApplicationNo"/>",{maxItemsToShow : 5});
当我在文本框中键入一些内容时,选项将出现在文本框中,并且当我选择/选择特定结果时,我希望调用一个单独的动作.
When I type some thing on the textbox, choices will appear in the text box and when I choose/select a particular result, I want a seperate action to be called.
<s:textfield name="loan.applicationNo" id="loanApplicationNo" theme="simple" />
<a id="depositSearch" class="example6 cboxElement" href="/casba-pa-war/ln/3106.action?from=7005" title="Customer Accounts Search" style="padding-left: 25px; padding-bottom: 25px; text-decoration: none; font-size: 12px;">
<img alt="search" src="../images/search.jpeg" border="0px"/>
</a>
我如何实现这一目标.我尝试了很多,但未能执行单独的选择操作.
How can I achieve this.I tried a lot but failed to fire a seperate action for selection.
推荐答案
url
标记用于根据动作名称和/或名称空间属性来构建和呈现动作就绪URL,也可以对其进行参数设置. action
属性应包含有效的操作名称,而不是路径.
The url
tag is used to build and render the action ready URL from the action name and/or namespace attributes, and also could be parametrized. The action
attribute should contain the valid action name not the path.
$("#loanApplicationNo").autocomplete({
source: function(request, response) {
$.getJSON('<s:url action="suggestByLoanApplicationNo"/>', {
term: extractLast(request.term)
}, response);
}
});
该操作应返回json
结果,如果将程序包配置为扩展json-default
,则该结果可用.
The action should return json
result that is available if you configure the package to extend the json-default
.
这篇关于如何在Struts2中为选择(选择事件)提供单独的操作(在自动完成文本框中使用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!