1 7 8 package poker.presentation.main; 9 10 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 org.w3c.dom.html.HTMLTableElement; 16 import org.w3c.dom.html.HTMLTableRowElement; 17 import org.w3c.dom.html.HTMLAnchorElement; 18 19 import poker.Poker; 20 import poker.spec.PokerGame; 21 import poker.spec.GameManager; 22 23 import java.util.Vector ; 24 25 public class ScoresPresentation implements HttpPresentation { 26 27 28 public void run(HttpPresentationComms comms) 29 throws HttpPresentationException, KeywordValueException { 30 31 ScoresHTML scores; 32 scores = (ScoresHTML)comms.xmlcFactory.create(ScoresHTML.class); 33 34 HTMLTableRowElement dummyRow = (HTMLTableRowElement)scores.getElementDummyRow(); 35 HTMLTableElement table = (HTMLTableElement)scores.getElementScoreTable(); 36 37 Poker mainApp = (Poker)comms.session.getSessionData().get("app"); 38 GameManager gameManager = mainApp.getGameManager(); 39 40 41 46 try{ 47 Vector topTen = gameManager.getTopTen(); 48 49 PokerGame game; 50 for (int i = 0; i < 10; i++) { 51 game = (PokerGame)topTen.elementAt(i); 52 if (!game.getName().equals("")) { 53 scores.setTextNumbers(Integer.toString(i)); 54 scores.setTextName(game.getName()); 55 scores.setTextCach(Integer.toString(game.getCash())); 56 HTMLAnchorElement a = scores.getElementEmail(); 57 a.setHref("MAILTO:" + game.getEmail()); 58 scores.setTextHands(Integer.toString(game.getTotalPlayed())); 59 } 60 else { 61 scores.setTextNumbers(Integer.toString(i)); 62 scores.setTextName(" "); 63 scores.setTextCach(" "); 64 HTMLAnchorElement a = scores.getElementEmail(); 65 a.setHref("MAILTO:a@a.co.yu"); 66 scores.setTextHands(" "); 67 } 68 HTMLTableRowElement clonedRow = (HTMLTableRowElement)dummyRow.cloneNode(true); 69 table.insertBefore(clonedRow, table.getLastChild()); 70 } 71 72 table.removeChild(dummyRow); 73 }catch (NullPointerException e){} 74 comms.response.writeDOM(scores); 75 } 76 77 } 78 | Popular Tags |