Struts 2的Ajax jQuery插件 [英] Ajax jQuery plugin with Struts 2

查看:80
本文介绍了Struts 2的Ajax jQuery插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在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应该包含idname属性,因此OGNL也可以访问它.

The Country bean should contain id and name properties, so it also accessible to OGNL.

这篇关于Struts 2的Ajax jQuery插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆