<repo_name>Annette70/springmvc<file_sep>/src/main/resources/message.properties
typeMismatch.theCustomer.freePasses=Must be a number<file_sep>/src/main/java/edu/wctc/customer/controller/CustomerController.java
package edu.wctc.customer.controller;

import edu.wctc.customer.entity.Customer;
import edu.wctc.customer.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.validation.Valid;
import java.util.List;

@Controller
@RequestMapping("/validation")
public class CustomerController {

    @Autowired
    private CustomerService customerService;


    @RequestMapping("/list")
    public String showCustomerList(Model model){
        List<Customer> list = customerService.getCustomerList();
        model.addAttribute("allCustomers", list);
        return "customer/customer-list";
    }

    @InitBinder
    public void trimWhitespace(WebDataBinder dataBinder){
        StringTrimmerEditor ste = new StringTrimmerEditor(true);
        dataBinder.registerCustomEditor(String.class, ste);
    }

    @RequestMapping("/form")
    public String showForm(Model model){
        model.addAttribute("theCustomer", new Customer());
        return "customer/customer-form";
    }

    @RequestMapping("/processForm")
    public String orderTickets(@Valid @ModelAttribute("theCustomer") Customer theCustomer,
                               BindingResult validation){
        System.out.println(theCustomer.toString());

        if (validation.hasErrors()) {
            return "customer/customer-form";
        }
        return "customer/customer-confirmation";
    }
}
<file_sep>/src/main/java/edu/wctc/customer/dao/CustomerDAO.java
package edu.wctc.customer.dao;

import edu.wctc.customer.entity.Customer;

import java.util.List;

public interface CustomerDAO {
    List<Customer> getCustomerList();
}
<file_sep>/src/main/java/edu/wctc/customer/service/LastNameSortingCustomerService.java
package edu.wctc.customer.service;

import edu.wctc.customer.dao.CustomerDAO;
import edu.wctc.customer.entity.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;

@Service
public class LastNameSortingCustomerService implements CustomerService {

    @Autowired
    private CustomerDAO customerDAO;

    @Override
    public List<Customer> getCustomerList() {
        List<Customer> list= customerDAO.getCustomerList();
        list.sort(Comparator.comparing(Customer::getLastName));

        return null;
    }
}
<file_sep>/src/main/java/edu/wctc/travel/TravelController.java
package edu.wctc.travel;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

@Controller
@RequestMapping("/travel")
public class TravelController {

    @Value("#{gradeLevelProp}")
    private Map<Integer, String> gradeLevelMap;

    @RequestMapping("/showForm")
    public String showForm(Model model){
        ExchangeStudent es = new ExchangeStudent();
        model.addAttribute("exchStudent",es);

        model.addAttribute("countries", new CountryOptions());

        model.addAttribute("gradeLevels", gradeLevelMap);

        model.addAttribute("travelMethods", TravelMethod.values());

        return "travelOutput/form";
    }
    @RequestMapping("/processForm")
    public String processForm(@ModelAttribute("exchStudent") ExchangeStudent es){
        return "travelOutput/confirm";
    }



}
