KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > poker > presentation > login > LoginPresentation


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

7
8 package poker.presentation.login;
9
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
20     public void run(HttpPresentationComms comms)
21         throws HttpPresentationException, KeywordValueException {
22
23         LoginHTML login;
24         login = (LoginHTML)comms.xmlcFactory.create(LoginHTML.class);
25
26         // Get the initial text for the username (if any).
27
String JavaDoc username = (String JavaDoc)comms.session.getSessionData().get("oname");
28         String JavaDoc password = "";
29         String JavaDoc cash = "";
30           String JavaDoc id = comms.session.getSessionKey();
31           String JavaDoc m = (String JavaDoc)comms.session.getSessionData().get("loginMessage");
32           if (m != null) {
33           login.setTextMessage(m);
34         }
35         else
36           login.setTextMessage("Enter your username, password and desired" +
37                                 " additional cash amount!");
38
39         if (username == null || username.equals("")) {
40           username = comms.request.getParameter("username");
41           password = comms.request.getParameter("pw");
42           cash = comms.request.getParameter("cash");
43         }
44         if (username == null || username.equals("")) {
45           username = comms.request.getParameter("");
46           password = comms.request.getParameter("");
47           cash = comms.request.getParameter("");
48         }
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 }
75
Popular Tags