Skip to main content

Ajax call response in struts. Response not reflected in jsp.



I am calling a struts action on using an ajax call. In it i am changing the values of some properties of the action class. The values are set properly but i am not able to reflect the changes in the jsp.





The jsp code is as follows.







<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



<%@ taglib prefix="s" uri="/struts-tags"%>

<html>

<head>

function findindex1()

{

var temp=document.getElementById("country").value;

if(window.ActiveXObject){ request = new ActiveXObject("Microsoft.XMLHTTP"); }

else if(window.XMLHttpRequest){ request = new XMLHttpRequest(); } request.onreadystatechange = showResult;

request.open("POST",'temp.action?index='+temp,true);

request.send(null);

}

function showResult(){

if(request.readyState == 4){

document.getElementById("city").flush();

}

}

</head>

<body onload="fill()">

<s:form method="post" action="product.action" name="product" theme="simple">

<table id="table">

<tr><td>Country</td><td><s:select id="country" name="country.countryId" list="countryList" listKey="countryId"

listValue="name" onchange="findindex1()" ></s:select></td></tr>

<tr>

<td>City</td>

<td><s:select id="city" name="city.id" list="cities" listKey="id"

listValue="name" headerKey="city.id" ></s:select></td>

</tr>



<tr>

<td><s:submit id="search" name="submit" value="Search"></s:submit></td>

<td><s:submit name="submit" value="Create"></s:submit>

</td>

</tr>

</table>

</s:form>

</body>

</html>







The action class method is as follows ...







public String temp(){

String[] id=(String[])getParameters().get("index"); //get the country index

index=Integer.parseInt(id[0]);

cities=(ArrayList<City>)productCreateService.selectCities(Integer.parseInt(id[0])); //populate corresponding cities



return SUCCESS;

}







Up till this it is working . The call to this method is executed and the cities(which represent the dropdown list) is populated properly. All now i want is to reflect this updated cities in jsp. I cant seem to do that.





Can anyone help .... ???





Note: I have used the flush function for no particular purpose but just for hit and trial.





P.S. : I know the code is a little vague. So if any more information is needed please let me know ...





Thanks


Comments

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?

CCNA 3 Final Exam => latest version

1 . Which security protocol or measure would provide the greatest protection for a wireless LAN? WPA2 cloaking SSIDs shared WEP key MAC address filtering   2 . Refer to the exhibit. All trunk links are operational and all VLANs are allowed on all trunk links. An ARP request is sent by computer 5. Which device or devices will receive this message? only computer 4 computer 3 and RTR-A computer 4 and RTR-A computer 1, computer 2, computer 4, and RTR-A computer 1, computer 2, computer 3, computer 4, and RTR-A all of the computers and the router   3 . Refer to the exhibit. Hosts A and B, connected to hub HB1, attempt to transmit a frame at the same time but a collision occurs. Which hosts will receive the collision jamming signal? only hosts A and B only hosts A, B, and C only hosts A, B, C, and D only hosts A, B, C, and E   4 . Refer to the exhibit. Router RA receives a packet with a source address of 192.168.1.65 and a destination address of 192.168.1.161...