javadev-chiennx / struts2-jquery-plugin

Automatically exported from code.google.com/p/struts2-jquery-plugin
0 stars 0 forks source link

sj:select issue - version 2.5 - Cannot use root element as list #28

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create an action with the following annotation:
@Action(value="some-action",results={
   @Result(name="LIST",type="json", params={"root","conditionTypes"})
})
public class SomeAction
    extends BaseAction
...

2.
And the following method
public String list(){
  conditionTypes.put("opt1","opt1"));
  conditionTypes.put("opt2","opt2"));
  ...
  return "LIST";
}

3. The jsp looks like:
<s:url id="remoteurl" action="some-action!list" />
<sj:select  
  href="%{remoteurl}"     
  id="conditionType"         
  name="conditionType"     
  dataType="json"
  emptyOption="false"         
/>

Wat is the expected output? What do you see instead?
At this point I expect the json output to populate the select options but I 
don't get any options.

I am getting JSON output:
{"10":"File Size","11":"Number Of Files","4":"File Content","9":"Last Modified 
Date"}

But jquery never seems to do the binding to the select element.

The rendered tag looks like:
<select name="conditionType" id="conditionType" jQuery1291246451525="25">

<script type="text/javascript">
jQuery(document).ready(function () {  
var options_conditionType = {};  
options_conditionType.datatype = "json";  
options_conditionType.type = 'select';  
options_conditionType.list = ".";  
options_conditionType.jqueryaction = "select";  
options_conditionType.id = "conditionType";  
options_conditionType.name = "conditionType";  
options_conditionType.href = "/MyApp/some-action!list.action";  
options_conditionType.datatype = "json";     
jQuery.struts2_jquery.bind(jQuery('#conditionType'),options_conditionType);   
});
</script>

What version of the product are you using? On what operating system?
2.5, windows.

Please provide any additional information below.
I would have thought that where the optional "list" attribute is left blank it 
would know to bind at the root element but it doesn't seem to work that way.

Original issue reported on code.google.com by davpat2...@gmail.com on 1 Dec 2010 at 11:56