package net.sevecek.zakladniwebapp;

import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.*;

@Controller
public class HlavniController {

    @RequestMapping(value = "/ukazka.html",
            method = RequestMethod.GET)
    public ModelAndView zobrazUkazku() {
        ModelAndView modelAndView = new ModelAndView(
                "/WEB-INF/view/ukazka.jsp");
        return modelAndView;
    }

    @RequestMapping(value = "/ukazka.html",
            method = RequestMethod.POST)
    public ModelAndView zpracujUkazku(UkazkaForm vyplnenyFormular) {
        ModelAndView modelAndView = new ModelAndView(
                "/WEB-INF/view/vysledek.jsp");

        String celeJmeno = vyplnenyFormular.getJmeno() + " "
                + vyplnenyFormular.getPrijmeni();
        modelAndView.addObject("kompletniJmeno",
                celeJmeno);

        return modelAndView;
    }

}
