What steps will reproduce the problem?
some .ftl like this:
<@s.select name="key1" id="key1" list=list2 listKey="key" listValue="text"
multiple="false" size="1" onchange="javascript: return changeMe(this);" />
<@s.url id="id1" action="action1" method="populate" escapeAmp=false />
<@sj.select id="id2"
name="id2"
href="%{id1}"
reloadTopics="reload"
elementIds="key1"
list="list"
listKey="key"
listValue="text"
dataType="json"
indicator="indicator"
/>
<img id="indicator" class="indicator" src="<@s.url
value="/share/images/wait/indicator.gif" />" alt="Loading..."/>
in the xml action conf:
<interceptor-ref name="json">
<param name="contentType">application/json</param>
</interceptor-ref>
...
<result name="json-populate" type="json">
<param name="root">list</param>
</result>
...
java
private Integer key1;//getter and setter ok
private List<LookUpItem<Integer>> list;
//getter and setter are ok, the class LookUpItem is a bean with integer key and
text description
public String populate() throws Exception {
loadList();
return "json-populate";
}
javascript:
changeMe(me) {
...
$.publish('reload');
...
}
What is the expected output? What do you see instead?
json load but json was not load.
What version of the product are you using? On what operating system?
I use struts2 2.1.8.1 no annotation, xml conf.
struts2-jquery-plugin 3.2.0
struts2-json-plugin 2.1.8.1
ubuntu maverick 64bit
Please provide any additional information below.
1. if I look at action1!populate.action output
I can see a pretty array of object in json format
2. the first select do his job by update key1 before try to update the
secon select
but the second select do not update his value!!!
so I use hammer and chenge this on ftl on the second select:
dataType="json" to -> dataType="html"
amd add
onSuccessTopics="handleJsonResult"
in the javascipt add:
jQuery(document).ready( function() {
$.subscribe('handleJsonResult', function(event,data) {
var obj= jQuery.parseJSON(event.originalEvent.data);
var list = $('#id2');
$.each(obj, function(index, value) {
list.append('<option value='+value.key+'>'+value.text+'</option>\n');
});
});
});
then all work fine!!!
my question: why have I to do this last change to let work the code?
why the first scenario do not work?
Original issue reported on code.google.com by leonardo...@gmail.com on 14 Nov 2011 at 3:25
Original issue reported on code.google.com by
leonardo...@gmail.com
on 14 Nov 2011 at 3:25