View Javadoc

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.ChosenRoomBean;
12  import pl.agh.iosr.ballamigos.webapp.core.WebApplicationCommunicator;
13  
14  /***A struts action class used to move the player to the room he chose and to save the name of this room
15   * as a session attribute.
16   * 
17   * @author Piotr
18   *
19   */
20  public class ChooseRoomAction extends BallAmigosAction {
21  
22  	public ActionForward execute(ActionMapping mapping,
23  			ActionForm form,
24  			HttpServletRequest request,
25  			HttpServletResponse response)
26  	throws Exception {
27  		HttpSession session = request.getSession();
28  		
29  		if(playerLoggedIn(request)) {
30  			String room = ((ChosenRoomBean)form).getRoom();
31  			
32  			session.setAttribute("room", room);
33  			((WebApplicationCommunicator)session.getAttribute("communicator")).moveToRoom(room);
34  			
35  			return(mapping.findForward("success"));
36  		}
37  		else return(mapping.findForward("failure"));	
38  	}	
39  	
40  }