KickJava   Java API By Example, From Geeks To Geeks.

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


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

7
8 package poker.presentation.main;
9
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
23   public void run(HttpPresentationComms comms)
24       throws HttpPresentationException, KeywordValueException {
25
26     HouseHTML house;
27     house = (HouseHTML)comms.xmlcFactory.create(HouseHTML.class);
28
29     Poker mainApp = (Poker)comms.session.getSessionData().get("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.getTotalHandsDealt());
40     house.setTextTotalHandsLost(gameManager.getTotalHandsLost());
41     house.setTextTotalHandsWon(gameManager.getTotalHandsWon());
42     house.setTextTotalPlayers(gameManager.getTotalPlayers());
43
44 }catch (NullPointerException JavaDoc e){}
45
46     comms.response.writeDOM(house);
47   }
48
49 }
50
Popular Tags