01: /*
02: * Poker
03: *
04: * Enhydra super-servlet presentation object
05: *
06: */
07:
08: package poker.presentation.main;
09:
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: public void run(HttpPresentationComms comms)
25: throws HttpPresentationException, KeywordValueException,
26: SessionException {
27:
28: BankruptHTML bankrupt;
29: bankrupt = (BankruptHTML) comms.xmlcFactory
30: .create(BankruptHTML.class);
31:
32: Poker mainApp = (Poker) comms.session.getSessionData().get(
33: "app");
34: GameManager gameManager = mainApp.getGameManager();
35: PokerGame game = (PokerGame) comms.session.getSessionData()
36: .get("game");
37:
38: HTMLInputElement input = null;
39: String temp = null;
40:
41: temp = game.getName();
42: input = bankrupt.getElementUsername();
43: if (temp != null) {
44: bankrupt.setTextName(temp);
45: input.setValue(temp);
46: } else {
47: bankrupt.setTextName("");
48: input.setValue("");
49: }
50:
51: temp = game.getPassword();
52: input = bankrupt.getElementPassword();
53: if (temp != null)
54: input.setValue(temp);
55: else
56: input.setValue("");
57:
58: temp = game.getEmail();
59: input = bankrupt.getElementEmail();
60: if (temp != null)
61: input.setValue(temp);
62: else
63: input.setValue("");
64:
65: gameManager.removeGame(game.getName());
66: comms.session.setUser(null);
67: String message = "User is bankrupt and removed!";
68: comms.session.getSessionData().set("error", message);
69:
70: comms.response.writeDOM(bankrupt);
71: }
72:
73: }
|