1
我有那里的组合列表。国家,州和城市。我需要根据以前的combolist更改列表,如果我更改了国家我需要获得该国家的相应状态列表,并且如果我选择状态,那么该州的相应城市。任何人都可以请帮我找到答案。由于3依赖下拉使用struts和休眠(国家,州,市)
public String getStateNCityList() {
logger.info("Enter getStateNCityList");
try {
AddressUtils addrUtil = new AddressUtils();
this.stateList = addrUtil.getStateList(this.getCountryId());
this.cityList = addrUtil.getCityList(this.getStateList().get(0).getAddressComboId());
this.session.put("stateList", this.stateList);
this.session.put("cityList", this.cityList);
System.out.println("state list size "+this.stateList.size());
System.out.println("city list size "+this.cityList.size());
} catch(Exception e) {
logger.error(e,e);
return ERROR;
}
logger.info("Exit getStateNCityList");
return SUCCESS;
}
//addressUtils.java
public List<AddressComboDetails> getCountryList(){
List<AddressComboDetails> countryList = new ArrayList<AddressComboDetails>();
try{
String query=" addressComboTypeId="+ApplicationConstants.COMBO_COUNTRY;
countryList=addressDao.getAddressComboDetailsByWhereClause(query);
System.out.println("countryList size" +countryList.size());
} catch(Exception e) {
logger.error("Exception in getCountryList");
logger.error(e,e);
}
return countryList;
}
//冬眠Java类
public List<AddressComboDetails> getAddressComboDetailsByWhereClause(
String whereClause) {
logger.info("entered getAddresscomboDetailsByWhereClause ");
List<AddressComboDetails> addressComboList = new ArrayList<AddressComboDetails>();
Session session = null;
try {
session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
String query = " from AddressComboDetails where " + whereClause;
System.out.println("Query is "+query);
addressComboList = (List<AddressComboDetails>) session.createQuery(query).list();
tx.commit();
} catch (HibernateException e) {
logger.error("error in getAddresscomboDetailsByWhereClause"+ e.getMessage());
logger.error(e,e);
} finally {
session.close();
}
return addressComboList;
}
//我的jsp页面代码
<tr>
<td class="generalText"><s:text name="country" /></td>
<td><s:select listValue="addressComboValue" listKey="addressComboId" list="#session.countryList" onchange="dojo.event.topic.publish('address_country_details');return false;"
name="corpAddress.country.addressComboId" />
<s:set name="countryId" value="%{corpAddress.country.addressComboId}" /></td>
<td><s:url id="corp_country" action="getStateNCityList.action" >
<s:param name="countryId" value="%{11}"></s:param></s:url>
<sx:div id="country" cssStyle="display:none;" href="%{corp_country}" listenTopics="address_country_details" formId="supplierDetails" showLoadingText=""></sx:div>
</tr>
@ JB Nizet:我尝试了一切,但我无法显示列表。我也获得了大小。我正在使用dojo发布并调用该操作。如果你有任何代码或者其他东西,那么请让我知道。这将是非常友善的。感谢回复 – Ani 2011-03-23 14:37:24
@Ani:告诉我们你遇到问题的代码,告诉我们你期待什么,取而代之的是什么。我们愿意提供帮助,但不会为您实施所有应用。 – 2011-03-23 14:44:10
@JB Nizet:我已经更新了我的代码。可以请我为我的问题找到解决方案。我无法在jsp页面中弹出列表数据。但是我可以从数据库中正确地获取列表。我正在使用pgsql。 – Ani 2011-03-23 14:56:20