1 package pl.agh.iosr.ballamigos.webapp.actions;
2
3 import javax.servlet.http.HttpServletRequest;
4 import javax.servlet.http.HttpServletResponse;
5 import javax.servlet.http.HttpSession;
6
7 import org.apache.struts.action.ActionForm;
8 import org.apache.struts.action.ActionForward;
9 import org.apache.struts.action.ActionMapping;
10
11 import pl.agh.iosr.ballamigos.webapp.beans.MatchNameBean;
12 import pl.agh.iosr.ballamigos.webapp.core.WebApplicationCommunicator;
13
14 /***A struts action class used to create a match, after the user has chosen a name for it.
15 *
16 * @author Piotr
17 *
18 */
19 public class ChooseMatchName extends BallAmigosAction {
20 public ActionForward execute(ActionMapping mapping,
21 ActionForm form,
22 HttpServletRequest request,
23 HttpServletResponse response)
24 throws Exception {
25 if(playerLoggedIn(request)) {
26 HttpSession session = request.getSession();
27 String mn = ((MatchNameBean)form).getMatchName();
28
29 ((WebApplicationCommunicator)session.getAttribute("communicator")).createMatch(mn);
30 session.setAttribute("matchName", mn);
31 return(mapping.findForward("success"));
32 }
33 else return(mapping.findForward("failure"));
34 }
35 }