01: /*
02: * Poker
03: *
04: * Enhydra super-servlet presentation object
05: *
06: */
07:
08: package poker.presentation.login;
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 com.lutris.util.KeywordValueException;
15: import org.w3c.dom.html.HTMLInputElement;
16:
17: public class LoginPresentation implements HttpPresentation {
18:
19: public void run(HttpPresentationComms comms)
20: throws HttpPresentationException, KeywordValueException {
21:
22: LoginHTML login;
23: login = (LoginHTML) comms.xmlcFactory.create(LoginHTML.class);
24:
25: // Get the initial text for the username (if any).
26: String username = (String) comms.session.getSessionData().get(
27: "oname");
28: String password = "";
29: String cash = "";
30: String id = comms.session.getSessionKey();
31: String m = (String) comms.session.getSessionData().get(
32: "loginMessage");
33: if (m != null) {
34: login.setTextMessage(m);
35: } else
36: login
37: .setTextMessage("Enter your username, password and desired"
38: + " additional cash amount!");
39:
40: if (username == null || username.equals("")) {
41: username = comms.request.getParameter("username");
42: password = comms.request.getParameter("pw");
43: cash = comms.request.getParameter("cash");
44: }
45: if (username == null || username.equals("")) {
46: username = comms.request.getParameter("");
47: password = comms.request.getParameter("");
48: cash = comms.request.getParameter("");
49: }
50:
51: // Store the values, so they can be acessed as html fields.
52:
53: HTMLInputElement input = null;
54: input = login.getElementId();
55: input.setValue(id);
56: input = login.getElementUsername();
57: input.setValue(username);
58: input = login.getElementPassword();
59: input.setValue(password);
60: input.setAttribute("type", "password");
61: input = login.getElementCash();
62: input.setValue(cash);
63:
64: input = login.getElementUsernameCreate();
65: input.setValue(username);
66: input = login.getElementPasswordCreate();
67: input.setValue(password);
68: input = login.getElementCashCreate();
69: input.setValue(cash);
70:
71: comms.response.writeDOM(login);
72: }
73:
74: }
|