KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.w3c.dom.html.HTMLInputElement;
15 import com.lutris.util.KeywordValueException;
16 import com.lutris.appserver.server.session.SessionException;
17
18 import poker.Poker;
19 import poker.spec.PokerGame;
20 import poker.spec.GameManager;
21
22 public class BankruptPresentation implements HttpPresentation {
23
24
25     public void run(HttpPresentationComms comms)
26         throws HttpPresentationException, KeywordValueException, SessionException {
27
28       BankruptHTML bankrupt;
29       bankrupt = (BankruptHTML)comms.xmlcFactory.create(BankruptHTML.class);
30
31       Poker mainApp = (Poker)comms.session.getSessionData().get("app");
32       GameManager gameManager = mainApp.getGameManager();
33       PokerGame game = (PokerGame)comms.session.getSessionData().get("game");
34
35       HTMLInputElement input = null;
36       String JavaDoc temp = null;
37
38       temp = game.getName();
39       input = bankrupt.getElementUsername();
40       if (temp != null) {
41         bankrupt.setTextName(temp);
42         input.setValue(temp);
43       }
44       else {
45         bankrupt.setTextName("");
46         input.setValue("");
47       }
48
49       temp = game.getPassword();
50       input = bankrupt.getElementPassword();
51       if (temp != null)
52         input.setValue(temp);
53       else
54         input.setValue("");
55
56       temp = game.getEmail();
57       input = bankrupt.getElementEmail();
58       if (temp != null)
59         input.setValue(temp);
60       else
61         input.setValue("");
62
63       gameManager.removeGame(game.getName());
64       comms.session.setUser(null);
65       String JavaDoc message = "User is bankrupt and removed!";
66       comms.session.getSessionData().set("error", message);
67
68       comms.response.writeDOM(bankrupt);
69   }
70
71 }
72
Popular Tags