1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.controller;
import com.dao.CityDAO;
import com.dao.CountryDAO;
import com.dao.RegionDAO;
import com.entities.City;
import com.entities.Country;
import com.entities.Region;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.model.SelectItem;
/**
*
* @author Dell
*/
public class AreaBean {
@EJB
private CountryDAO countryDAO;
private List<SelectItem> countryItems;
public String selectedCountry;
private List<Country> countryList;
@EJB
private RegionDAO regionDAO;
private List<SelectItem> regionItems;
private String selectedRegion;
private List<Region> regionList;
@EJB
private CityDAO cityDAO;
private List<SelectItem> cityItems;
private String selectedCity;
private List<City> cityList;
/**
* Creates a new instance of CountryBean
*/
public AreaBean() {
}
public String getSelectedCountry() {
return selectedCountry;
}
public void setSelectedCountry(String selectedCountry) {
this.selectedCountry = selectedCountry;
}
public List getCountryList() {
this.setCountryList(countryDAO.getCountryList());
return this.countryList;
}
public void setCountryList(List countryList) {
this.countryList = countryList;
}
public List<SelectItem> getCountryItems() {
countryItems = new ArrayList<SelectItem>();
Country c;
Iterator it = getCountryList().iterator();
while (it.hasNext()) {
c = (Country) it.next();
String codeint = String.valueOf(c.getId());
String codestr = String.valueOf(c.getCountryCode());
String name = String.valueOf(c.getCountryName());
countryItems.add(new SelectItem(codeint, "[" + codestr + "]" + "--" + name));
}
return countryItems;
}
public void setCountryItems(List<SelectItem> countryItems) {
this.countryItems = countryItems;
}
public RegionDAO getRegionDAO() {
return regionDAO;
}
public void setRegionDAO(RegionDAO regionDAO) {
this.regionDAO = regionDAO;
}
public List<SelectItem> getRegionItems() {
regionItems = new ArrayList<SelectItem>();
Region r;
Iterator it = getRegionList().iterator();
while(it.hasNext()){
r = (Region) it.next();
String codeint = String.valueOf(r.getId());
String codestr = String.valueOf(r.getCountryCode());
String name = String.valueOf(r.getCountryRegion());
regionItems.add(new SelectItem(codeint, "[" + codestr + "]" + "--" + name));
}
return regionItems;
}
public void setRegionItems(List<SelectItem> regionItems) {
this.regionItems = regionItems;
}
public String getSelectedRegion() {
return selectedRegion;
}
public void setSelectedRegion(String selectedRegion) {
this.selectedRegion = selectedRegion;
}
public List<Region> getRegionList() {
System.out.print(this.selectedRegion);
System.out.print(this.selectedCountry);
this.setRegionList(regionDAO.getRegionList());
return regionList;
}
public void setRegionList(List<Region> regionList) {
this.regionList = regionList;
}
public CityDAO getCityDAO() {
return cityDAO;
}
public void setCityDAO(CityDAO cityDAO) {
this.cityDAO = cityDAO;
}
public List<SelectItem> getCityItems() {
cityItems = new ArrayList<SelectItem>();
City ct;
Iterator it = getCityList().iterator();
while(it.hasNext()){
ct = (City) it.next();
String codeint = String.valueOf(ct.getId());
String name = String.valueOf(ct.getCityName());
cityItems.add(new SelectItem(codeint, name));
}
return cityItems;
}
public void setCityItems(List<SelectItem> cityItems) {
this.cityItems = cityItems;
}
public String getSelectedCity() {
return selectedCity;
}
public void setSelectedCity(String selectedCity) {
this.selectedCity = selectedCity;
}
public List<City> getCityList() {
System.out.print(this.selectedRegion);
System.out.print(this.selectedCountry);
this.setCityList(cityDAO.getCityList());
return cityList;
}
public void setCityList(List<City> cityList) {
this.cityList = cityList;
}
} |
Partager