package spring.mvc.sample.ctrl;

import static org.springframework.web.bind.annotation.RequestMethod.*;

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

import spring.mvc.sample.model.RadiobuttonsModel;
import spring.mvc.sample.model.Sex;
import spring.mvc.sample.model.UserInfo;

@Controller
public class SimpleController2 {

	@RequestMapping(value = "/reg_sample_1", method = GET)
	public String regSample1(UserInfo userInfo, ModelMap modelMap) {
		RadiobuttonsModel rm = new RadiobuttonsModel();
		rm.setSelectedIsbn("0");
		modelMap.addAttribute("radiobuttonsModel", rm);
		modelMap.addAttribute("sexList", Sex.getSexRadionButton());
		return "regSample1";
	}

	@RequestMapping(value = "/reg_sample_1_confirm", method = POST)
	public String regSample1Confirm(UserInfo userInfo, RadiobuttonsModel radiobuttonsModel) {
		userInfo.setSex(radiobuttonsModel.getSelectedIsbn());
		return "regSample1Confirm";
	}

	@RequestMapping(value = "/reg_sample_1_completion", method = POST)
	public String regSample1Completion(UserInfo userInfo) {
		return "regSample1Completion";
	}

}