1818import org .springframework .validation .FieldError ;
1919import org .springframework .web .bind .WebDataBinder ;
2020import org .springframework .web .bind .annotation .*;
21+ import org .woehlke .greenshop .customer .service .CountryService ;
2122import org .woehlke .greenshop .catalog .entities .Language ;
2223import org .woehlke .greenshop .catalog .entities .ProductDescription ;
2324import org .woehlke .greenshop .checkout .OrderService ;
@@ -41,6 +42,8 @@ public class UserController extends AbstractController {
4142 @ Inject
4243 private OrderService orderService ;
4344
45+ @ Inject
46+ private CountryService countryService ;
4447
4548 @ InitBinder
4649 public void initBinder (WebDataBinder binder ) {
@@ -111,7 +114,7 @@ public String addressBookEditForm(@PathVariable long addressId, Model model){
111114 Customer customer = customerService .findCustomerByEmail (customerEmail );
112115 model .addAttribute ("customer" ,customer );
113116 AddressBook customersAddress = customerService .findAddressById (addressId );
114- List <Country > allCountriesOrderByName = customerService .findAllCountriesOrderByName ();
117+ List <Country > allCountriesOrderByName = countryService .findAllCountriesOrderByName ();
115118 model .addAttribute ("allCountriesOrderByName" ,allCountriesOrderByName );
116119 CustomerAddressBean addressBean = new CustomerAddressBean ();
117120 addressBean .setGender (customersAddress .getGender ());
@@ -138,12 +141,12 @@ public String addressBookEditStore(
138141 model .addAttribute ("customer" ,customer );
139142 if (result .hasErrors ()){
140143 super .getDefaultBoxContent (model );
141- List <Country > allCountriesOrderByName = customerService .findAllCountriesOrderByName ();
144+ List <Country > allCountriesOrderByName = countryService .findAllCountriesOrderByName ();
142145 model .addAttribute ("allCountriesOrderByName" ,allCountriesOrderByName );
143146 return "addressBookEdit" ;
144147 } else {
145148 AddressBook persistentAddress = customerService .findAddressById (addressId );
146- Country country = customerService .findCountryById (customersAddress .getCountry ());
149+ Country country = countryService .findCountryById (customersAddress .getCountry ());
147150 persistentAddress .setCity (customersAddress .getCity ());
148151 persistentAddress .setCompany (customersAddress .getCompany ());
149152 persistentAddress .setCountry (country );
@@ -167,7 +170,7 @@ public String addressBookAddForm(Model model){
167170 String customerEmail = auth .getName ();
168171 Customer customer = customerService .findCustomerByEmail (customerEmail );
169172 model .addAttribute ("customer" ,customer );
170- List <Country > allCountriesOrderByName = customerService .findAllCountriesOrderByName ();
173+ List <Country > allCountriesOrderByName = countryService .findAllCountriesOrderByName ();
171174 model .addAttribute ("allCountriesOrderByName" ,allCountriesOrderByName );
172175 CustomerAddressBean addressBean = new CustomerAddressBean ();
173176 model .addAttribute ("customersAddress" ,addressBean );
@@ -182,13 +185,13 @@ public String addressBookAddPerform(@Valid CustomerAddressBean customersAddress,
182185 model .addAttribute ("customer" ,customer );
183186 if (result .hasErrors ()){
184187 super .getDefaultBoxContent (model );
185- List <Country > allCountriesOrderByName = customerService .findAllCountriesOrderByName ();
188+ List <Country > allCountriesOrderByName = countryService .findAllCountriesOrderByName ();
186189 model .addAttribute ("allCountriesOrderByName" ,allCountriesOrderByName );
187190 model .addAttribute ("customersAddress" ,customersAddress );
188191 return "addressBookAdd" ;
189192 } else {
190193 AddressBook persistentAddress = new AddressBook ();
191- Country country = customerService .findCountryById (customersAddress .getCountry ());
194+ Country country = countryService .findCountryById (customersAddress .getCountry ());
192195 persistentAddress .setCustomer (customer );
193196 persistentAddress .setCity (customersAddress .getCity ());
194197 persistentAddress .setCompany (customersAddress .getCompany ());
0 commit comments