1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
5 <link rel=
"stylesheet" type=
"text/css" href=
"ext/resources/css/ext-all.css">
6 <script type=
"text/javascript" src=
"ext/adapter/ext/ext-base.js"></script>
7 <script type=
"text/javascript" src=
"ext/ext-all.js"></script>
8 <script type=
"text/javascript">
9 Ext
.onReady(function(){
12 // Create a variable to hold our EXT Form Panel.
13 // Assign various config options as seen.
14 var login
= new Ext
.FormPanel({
19 defaultType
:'textfield',
21 // Specific attributes for the text fields for username / password.
22 // The "name" attribute defines the name of variables sent to the server.
24 fieldLabel
:'Username',
28 fieldLabel
:'Password',
34 // All the magic happens after the user clicks the button
38 // Function that fires when user clicks the button
40 login
.getForm().submit({
42 waitTitle
:'Connecting',
43 waitMsg
:'Sending data...',
45 // Functions that fire (success or failure) when the server responds.
46 // The one that executes is determined by the
47 // response that comes from login.asp as seen below. The server would
48 // actually respond with valid JSON,
49 // something like: response.write "{ success: true}" or
50 // response.write "{ success: false, errors: { reason: 'Login failed. Try again.' }}"
51 // depending on the logic contained within your server script.
52 // If a success occurs, the user is notified with an alert messagebox,
53 // and when they click "OK", they are redirected to whatever page
54 // you define as redirect.
57 var redirect
= 'MainServlet.y';
58 window
.location
= redirect
;
61 // Failure function, see comment above re: success and failure.
62 // You can see here, if login fails, it throws a messagebox
63 // at the user telling him / her as much.
65 failure:function(form
, action
){
66 if(action
.failureType
== 'server'){
67 obj
= Ext
.util
.JSON
.decode(action
.response
.responseText
);
68 Ext
.Msg
.alert('Login Failed!', obj
.errors
.reason
);
70 Ext
.Msg
.alert('Warning!', 'Authentication server is unreachable : ' + action
.response
.responseText
);
72 login
.getForm().reset();
80 // This just creates a window to wrap the login form.
81 // The login object is passed to the items collection.
82 var win
= new Ext
.Window({