KickJava   Java API By Example, From Geeks To Geeks.

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


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 CreatePlayerPresentation implements HttpPresentation {
18
19
20     public void run(HttpPresentationComms comms)
21         throws HttpPresentationException, KeywordValueException {
22
23         CreatePlayerHTML createPlayer;
24         createPlayer = (CreatePlayerHTML)comms.xmlcFactory.create(CreatePlayerHTML.class);
25
26           String JavaDoc name =(String JavaDoc)comms.request.getParameter("username");
27         String JavaDoc pw = (String JavaDoc)comms.request.getParameter("password");
28         String JavaDoc email = (String JavaDoc)comms.request.getParameter("email");
29         String JavaDoc cash = (String JavaDoc)comms.request.getParameter("cash");
30         String JavaDoc m = (String JavaDoc)comms.session.getSessionData().get("error");
31
32         if (m != null) {
33           createPlayer.setTextError(m);
34         }
35         else
36           createPlayer.setTextError("");
37
38         HTMLInputElement input = null;
39         if (name != null) {
40           input = createPlayer.getElementUsername();
41           input.setValue(name);
42         }
43           else {
44           input = createPlayer.getElementUsername();
45           input.setValue("");
46         }
47
48         if (pw != null) {
49           input = createPlayer.getElementPassword();
50           input.setValue(pw);
51           input.setAttribute("type","password");
52         }
53         else {
54           input = createPlayer.getElementPassword();
55           input.setValue("");
56         }
57
58         if (email != null) {
59           input = createPlayer.getElementEmail();
60           input.setValue(email);
61         }
62         else {
63           input = createPlayer.getElementEmail();
64           input.setValue("");
65         }
66         if (cash != null) {
67           input = createPlayer.getElementCash();
68           input.setValue(cash);
69         }
70         else {
71           input = createPlayer.getElementCash();
72           input.setValue("500");
73         }
74
75         comms.response.writeDOM(createPlayer);
76     }
77
78 }
79
Popular Tags