Struts 2的Ajax jQuery插件 [英] Ajax jQuery plugin with Struts 2
问题描述
我正在Struts2中使用Ajax jQuery插件罐.我已使用Ajax select标签填充列表,但列表未填充.如果我使用<sj:autocompleter>
标记,则可以正常工作.这是我的代码
I am using Ajax jQuery plugin jars with Struts2. I have used Ajax select tag populate the list but list is not populating. if i used <sj:autocompleter>
tag it works fine. This is my code
<sj:select name="countryId" list="countryList" listKey="id" listValue="name"
headerKey="" headerValue="--Select Country--"
onchange="document.forms[0].action='city_countryChange'; document.forms[0].submit(); return true;"
required="required"></sj:select>
<sj:select>
标记有什么问题?
推荐答案
使用sj:autocompleter
并说效果很好时,就使用了href
属性. sj:select
href
属性也可以用于填充由sj:select
呈现的HTML select
标记.每个标签的属性集略有不同,并且href
属性也与HTML select
标签中的属性不同.
When you used sj:autocompleter
, and you say that it works fine, you have used href
attribute. sj:select
href
attribute also could be used to populate HTML select
tag which is rendered by the sj:select
. The set of attributes is slightly different for each tag, and a href
attribute is also different than in HTML select
tag.
两个标签都可以使用href
属性,并且您应该提供由填充sj:select
标签的操作返回的JSON结果.但是,如果使用autocomplete=true
属性,则sj:select
的行为类似于sj:autocompleter
并生成input
标记而不是select
标记.您应该定义输出所需的HTML标记.
The href
attribute is available and used by both tags and you should supply JSON result returned by the action which populate the sj:select
tag. But if you use autocomplete=true
attribute then sj:select
behave like sj:autocompleter
and generate input
tag instead of select
tag. You should define which HTML tag you need for the output.
使用属性进行播放可能会严重改变渲染的HTML.如果将list
属性与sj:select
标记一起使用,而不使用autocomplete
属性,则执行结果时将呈现带有options
的简单select
.就像使用序数s:select
一样.因此,您应该为list
属性值提供吸气剂,例如
Playing with attributes could cardinal change the rendered HTML. If you use list
attribute with the sj:select
tag and don't use autocomplete
attribute then simple select
with options
will be rendered when the result is executed. It's the same like ordinal s:select
is used. Thus you should provide the getter for the list
attribute value like
public List<Country> getCountryList() {
return countryList;
}
Country
bean应该包含id
和name
属性,因此OGNL也可以访问它.
The Country
bean should contain id
and name
properties, so it also accessible to OGNL.
这篇关于Struts 2的Ajax jQuery插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!