Documente Academic
Documente Profesional
Documente Cultură
By NithyaVidhyaarthi
Purpose & Pre-requisites
This tutorial is intended to help developers who would
like to take up ExtJS as their major tool for web
application development.
This tutorial uses Ext 3.3.0 version for visual clarifications.
While most contents are still appropriate, it is strongly
suggested for the observer to pay attention to the
“changes.html” bundled with every release to cross-verify
new updates/ deprecation(s) if any.
10 - April - 2011 Designing a User-login panel with ExtJS 2
Author notes…
Hi there, we now begin with designing a user login panel
with ExtJS. Through out this lesson, I’d delivered much
like, I sit beside you in your living room and we jointly
design the login panel.
I also make an assumption that, you have the idea of
configuring ExtJs in your application. In case if you don’t,
kindly take a look at “Beginning ExtJs with ASP.NET – Part
two”, for gaining the basics with ExtJS.
10 - April - 2011 Designing a User-login panel with ExtJS 3
Our Roadmap
Create a form element.
Create three controls (2 input fields & a button).
Validations: fields should not be left blank, minimum
of three characters and a maximum of thirty
characters.
Provide intimation using tooltips when validations
are violated.
The authentication process should begin only if the
above regulations are observed.
function.
Ext coding uses "name : value" approach extensively.
TIPS
10 - April - 2011 Designing a User-login panel with ExtJS 8
Coding the first step…
Lets have a look at code of user name field first.
xtype: 'textfield'
fieldLabel: Specifies the text that
, fieldLabel: 'User name' appears to the left of the textbox.
, width: 150
width & id are self-explanatory.
allowBlank: Instructs Ext that this
, id: 'txtUserName'
control should not be left blank.
, allowBlank:false minLength: Specifies the minimum
, minLength:3
no of chars to be filled in.
maxLength: Specifies the max no of
, maxLength: 30 chars allowed.
10 - April - 2011 Designing a User-login panel with ExtJS 9
Designing the password field
Lets have a look at code of user name field first.
xtype: 'textfield‘
inputType: Specifies the text should
, fieldLabel: ‘Password' be interpreted as password.
, inputType: 'password‘
Note: Other than this property, rest of properties
, width: 150 are the same like any textfield.
, id: 'txtUserName'
, allowBlank:false
, minLength:3
, maxLength: 30
10 - April - 2011 Designing a User-login panel with ExtJS 10
Creating a form.
Now lets create a form panel. This would be a bit
different from defining a control. Lets create a variable
named "myform" .
var myform = new Ext.form.FormPanel({
width:400
, height: 250
, renderTo: document.body
, items:[] /* this is an empty items collection. */
});
function CheckValid()
{
if ( myform.getForm(). isValid() == true){
/* form is valid. We can proceed with authencation */
}
else{
/* form contains invalid values . Now error message placeholders would be
shown immediately right to the invalid controls. When hovered, would show
the tooltips.*/
}
}
10 - April - 2011 Designing a User-login panel with ExtJS 35
Wiring form validation & button
TIP
10 - April - 2011 Designing a User-login panel with ExtJS 36
Handlers and Listeners
There are occasion where we need to fire methods on
events. In Ext, we need to use the config “listeners” to
listen to events and fire appropriately.
Syntax: listeners:{eventName: YourMethodName}
Example: listeners:{click: CheckValid}
handler wires the default event with the control.
For example., the default event for button is click event.
In such cases, listeners:{click: CheckValid} = handler: CheckValid.
i.e., they are identical and mean one and the same.
For more info upon the events available for controls, kindly refer the
ExtJS documentation.
INFO
10 - April - 2011 Designing a User-login panel with ExtJS 40
Reading the values…
TIPS
application in browser.
Once the Ext message box is displayed (that within the
and welcomed.
10 - April - 2011 Designing a User-login panel with ExtJS 45
Next in future