Query query = em.createQuery("from country in class Country where country.siteId = :siteId order by country.countryName");
query.setParameter("siteId", siteId);
Iterator<?> iterator = query.getResultList().iterator();
Vector<LabelValueBean> vector = new Vector<LabelValueBean>();
while (iterator.hasNext()) {
Country country = (Country) iterator.next();
LabelValueBean bean = new LabelValueBean(country.getCountryName(), country.getCountryCode());
vector.add(bean);
}
LabelValueBean countries[] = new LabelValueBean[vector.size()];
vector.copyInto(countries);
form.setCountries(countries);
Country custCountry = CountryDAO.loadByCountryCode(siteId, form.getCustCountryCode());
Vector<LabelValueBean> stateVector = new Vector<LabelValueBean>();
if (custCountry != null) {
for (State state : custCountry.getStates()) {
LabelValueBean bean = new LabelValueBean(state.getStateName(), state.getStateCode());
stateVector.add(bean);
}
LabelValueBean states[] = new LabelValueBean[stateVector.size()];
stateVector.copyInto(states);
form.setCustStates(states);
}
else {
LabelValueBean states[] = {};
form.setCustStates(states);
}
custCountry = CountryDAO.loadByCountryCode(siteId, form.getBillingCustCountryCode());
stateVector = new Vector<LabelValueBean>();
if (custCountry != null) {
for (State state : custCountry.getStates()) {
LabelValueBean bean = new LabelValueBean(state.getStateName(), state.getStateCode());
stateVector.add(bean);
}
LabelValueBean states[] = new LabelValueBean[stateVector.size()];
stateVector.copyInto(states);
form.setBillingCustStates(states);
}
else {
LabelValueBean states[] = {};
form.setBillingCustStates(states);
}
custCountry = CountryDAO.loadByCountryCode(siteId, form.getShippingCustCountryCode());
stateVector = new Vector<LabelValueBean>();
if (custCountry != null) {
for (State state : custCountry.getStates()) {
LabelValueBean bean = new LabelValueBean(state.getStateName(), state.getStateCode());
stateVector.add(bean);
}
LabelValueBean states[] = new LabelValueBean[stateVector.size()];
stateVector.copyInto(states);