01: /*
02: * Poker
03: *
04: * Enhydra super-servlet presentation object
05: *
06: */
07:
08: package poker.presentation.main;
09:
10: import poker.Poker;
11: import poker.spec.GameManager;
12:
13: // Enhydra SuperServlet imports
14: import com.lutris.appserver.server.httpPresentation.HttpPresentation;
15: import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
16: import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
17: import com.lutris.util.KeywordValueException;
18: import poker.Poker;
19:
20: public class HousePresentation implements HttpPresentation {
21:
22: public void run(HttpPresentationComms comms)
23: throws HttpPresentationException, KeywordValueException {
24:
25: HouseHTML house;
26: house = (HouseHTML) comms.xmlcFactory.create(HouseHTML.class);
27:
28: Poker mainApp = (Poker) comms.session.getSessionData().get(
29: "app");
30: GameManager gameManager = mainApp.getGameManager();
31: /*
32: * Catch Null pointer exception ( we canot make a instances of classes from business layer when we run poker_pres )
33: * We need to allow poker_pres to be dynamic , so if the requested url is /poker_pres/..... the response
34: * will be default HTML page
35: */
36: try {
37: house.setTextHouseProfit(gameManager.getHouseProfit());
38: house.setTextTotalBankrupt(gameManager.getTotalBankrupt());
39: house.setTextTotalHandsDealt(gameManager
40: .getTotalHandsDealt());
41: house
42: .setTextTotalHandsLost(gameManager
43: .getTotalHandsLost());
44: house.setTextTotalHandsWon(gameManager.getTotalHandsWon());
45: house.setTextTotalPlayers(gameManager.getTotalPlayers());
46:
47: } catch (NullPointerException e) {
48: }
49:
50: comms.response.writeDOM(house);
51: }
52:
53: }
|