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
Post a Comment