2

I have a problem in loading the response to the select tag. I am trying to change the select Box based on the first one.

For this I am using Struts 2 with jQuery Ajax tags. I think I have all required stuff but the response is not tagging to the option but able to see the result in the JS of the view source of a browser.

Below is the code which I have written in JSP.

This is my first select Box:

<div class="type-text">
  <s:url id="remoteurl" action="getGlobalManufacturerJquery.action?mainId=title&subId=Add Title&selectedManufacturer=strUser&gameFileID=%{gameFileID}&gameFileName=%{gameFileName}&titleName=%{titleName}&titleID=%{titleID}"/>
                <sj:select 
                    href="%{remoteurl}" 
                    formIds="TitleGameHandsetsForm"
                    id="manufacturerName%{titleGameFilemappingID}" 
                    onChangeTopics="reloadsecondlist" 
                     name="manufacturerName%{titleGameFilemappingID}"
                    list="%{manufacturers}" 
                     listKey="%{globalManufacturer}"
                    
                    listValue="%{globalManufacturer}" 
                    emptyOption="true" 
                    headerKey="-1" 
                    headerValue="Select Global Manufacturer" 
                />
          </div>

And below is my second select box which should be on chaging the first value

 <div class="type-text">        
                 <s:url id="remoteurl" action="getGlobalModelJquery.action?mainId=title&subId=Add Title&selectedManufacturer=strUser&gameFileID=%{gameFileID}&gameFileName=%{gameFileName}&titleName=%{titleName}&titleID=%{titleID}"/>
                <sj:select 
                     
                    id="globalModel%{titleGameFilemappingID}" 
                    formIds="TitleGameHandsetsForm" 
                    reloadTopics="reloadsecondlist" 
                    name="modelFromSelect" 
                    list="%{modelList}" 
                    emptyOption="true" 
                    headerKey="-1" 
                    headerValue="Select Global Model"
                />
                </div>

And in the JSP there is no list available. But the server code is getting results which I can see in the source code of JS which is not able to append to the JSP of select box.

<select name="manufacturerName77" id="manufacturerName77">
<option value=""></option>
</select>
<script type='text/javascript'>
jQuery(document).ready(function () {
    var options_manufacturerName77 = {};
    options_manufacturerName77.datatype = "json";
    options_manufacturerName77.type = 'select';
    options_manufacturerName77.emptyoption = true;
    options_manufacturerName77.headerkey = "-1";
    options_manufacturerName77.headervalue = "Select Global Manufacturer";
    **options_manufacturerName77.list = "[Acer, A Panda]";**
    options_manufacturerName77.listkey = "Acer";
    options_manufacturerName77.listvalue = "Acer";
    options_manufacturerName77.jqueryaction = "select";
    options_manufacturerName77.id = "manufacturerName77";
    options_manufacturerName77.name = "manufacturerName77";
    options_manufacturerName77.oncha = "reloadsecondlist";
    options_manufacturerName77.href = "/ci/getGlobalManufacturerJquery.action";
    options_manufacturerName77.hrefparameter = "mainId=title&subId=Add Title&selectedManufacturer=strUser&gameFileID=3&gameFileName=dcdscd&titleName=Bubble boom chalenge&titleID=11";
    options_manufacturerName77.formids = "TitleGameHandsetsForm";
  

jQuery.struts2_jquery.bind(jQuery('#manufacturerName77'),options_manufacturerName77);

 });
</script>
          </div>
Roman C
  • 49,761
  • 33
  • 66
  • 176
Krish
  • 199
  • 1
  • 3
  • 8

1 Answers1

0

If the URL is written incorrectly nothing will be returned by the action that should return JSON data for the list. You should write the URL like

<s:url var="remoteurl" action="getGlobalManufacturerJquery">
  <s:param name="mainId" value="title"/>
  <s:param name="subId" value="Add Title"/>
  <s:param name="selectedManufacturer" value="strUser"/>
  <s:param name="gameFileID" value="%{gameFileID}"/>
  <s:param name="gameFileName" value="%{gameFileName}"/>
  <s:param name="titleName" value="%{titleName}"/>
  <s:param name="titleID" value="%{titleID}"/>
</s:url>
Roman C
  • 49,761
  • 33
  • 66
  • 176
  • Hi Thanks for the reply Roman.Even after correcting the s:url the output has not changed. Below is the source code of the html. – Krish Mar 27 '13 at 09:41
  • If you want the second grid to reload then you should supply it with `reloadTopics`. – Roman C Mar 27 '13 at 09:51
  • Try to change the name or better copy/paste the working grid before you trying to `reloadTopics`. – Roman C Mar 27 '13 at 10:02