package com.httpunitsample.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.httpunitsample.form.RegistrationForm;

@Controller
public class RegistrationController {

	@RequestMapping(value = "/registrationForm")
    public String registration(Model model) {
		RegistrationForm registrationForm=new RegistrationForm();
		List<String> countryList=new ArrayList<String>();
		countryList.add("America");
		countryList.add("India");
        model.addAttribute("countryList",countryList);
        List<String> genderList=new ArrayList<String>();
        genderList.add("Female");
        genderList.add("Male");
        genderList.add("Dont want to say");
        model.addAttribute("genderList", genderList);
        //Set default value in gender list dropdown.
        registrationForm.setGender("Dont want to say");
        model.addAttribute("registrationForm", registrationForm);
        return "Registration";
	}
	
	@RequestMapping(value = "/registrationSubmit")
    public String registerUser(RegistrationForm registrationForm,Model model) {
		model.addAttribute("name",registrationForm.getName());
        return "Hello";
	}
}
