KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > poker > presentation > main > QuitPresentation


1 /*
2  * Poker
3  *
4  * Enhydra super-servlet presentation object
5  *
6  */

7
8 package poker.presentation.main;
9
10 // Enhydra SuperServlet imports
11
import com.lutris.appserver.server.httpPresentation.HttpPresentation;
12 import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
13 import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
14 import com.lutris.util.KeywordValueException;
15 import com.lutris.appserver.server.session.SessionException;
16
17 import poker.Poker;
18 import poker.spec.PokerGame;
19 import poker.spec.GameManager;
20
21 public class QuitPresentation implements HttpPresentation {
22
23     public void run(HttpPresentationComms comms)
24         throws HttpPresentationException, SessionException, KeywordValueException {
25
26         QuitHTML quit;
27         quit = (QuitHTML)comms.xmlcFactory.create(QuitHTML.class);
28
29         Poker mainApp = (Poker)comms.session.getSessionData().get("app");
30         GameManager gameManager = mainApp.getGameManager();
31         PokerGame game = (PokerGame)comms.session.getSessionData().get("game");
32
33 /*
34  * Catch Null pointer exception ( we canot make a instances of classes from business layer when we run poker_pres )
35  * We need to allow poker_pres to be dynamic , so if the requested url is /poker_pres/..... the response
36  * will be default HTML page
37  */

38 try{
39         String JavaDoc name = game.getName();
40         quit.setTextName(name);
41
42         comms.session.setUser(null);
43         if (game.getCash() < 1){
44            gameManager.removeGame(name);
45         }
46 }catch (NullPointerException JavaDoc e){}
47         comms.response.writeDOM(quit);
48     }
49
50 }
51
Popular Tags