nikolayLevin
13 Jul 2010, 12:43 AM
hello evrybody, i would like to make a login panel with sencha touch for iphones, i used touch library and i want to use JSP to check user informations. I can not send form values to JSP file. What is wrong with my code?
Login.js file;
Ext.setup({
onReady: function(){
var formBase = {
scrool: 'vertical',
items: [{
xtype: 'fieldset',
title: 'Login',
defaults : {
required : true,
labelAlign: 'left'
},
items : [
{
xtype: 'textfield',
name: 'name',
placeholder: 'Kullanici Adi / UserName'
},{
xtype: 'passwordfield',
name: 'password',
placeholder: 'Sifre / Password'
},
{
xtype: 'select',
name : 'language',
label: 'Dil/Language',
options: [
{text: 'Turkce', value: 'turkish'},
{text: 'English', value: 'english'}
]
}
]
}
],
dockedItems :[{
xtype : 'toolbar',
dock : 'bottom',
items : [
{
text: 'Login',
ui:'action',
handler : function(){
Ext.getBody().mask(false, '<div class="demos-loading">Loading…</div>');
Ext.Ajax.request({
url: 'loginUser.jsp',
method: 'post',
params: loginForm.getValues(),
success: function(response, opts) {
x = Ext.decode(response.responseText);
if (x.errorMessage != null)
alert(x.errorMessage);
else {
mainPanel.setCard(dashboard, 'slide');
}
Ext.getBody().unmask();
}
});
}
},
{
text: 'Reset',
handler: function(){
form.reset();
}
}
]
}]
};
if (Ext.platform.isAndroidOS) {
formBase.items.unshift({
xtype: 'component',
styleHtmlContent: true,
html: '<span style="color: red">Forms on Android are currently under development. We are working hard to improve this in upcoming releases.</span>'
});
}
if (Ext.platform.isPhone) {
formBase.fullscreen = true;
} else {
Ext.apply(formBase, {
autoRender: true,
floating: true,
modal: true,
centered: true,
hideOnMaskTap: false,
height: 385,
width: 480
});
}
var form = new Ext.form.FormPanel(formBase);
form.show();
}
}
)
Login.JSP file;
<%
String result;
String loginUsername = request.getParameter("name");
if (null != loginUsername && loginUsername.length() > 0) {
if (loginUsername.equals("name"))
result = "{success:true}";
else
result = "{success:false,errors:{reason:'Login failed.Try again'}}";
} else {
result = "{success:false,errors:{reason:'Login failed.Try again'}}";
}
%>
<%=result %>
Login.js file;
Ext.setup({
onReady: function(){
var formBase = {
scrool: 'vertical',
items: [{
xtype: 'fieldset',
title: 'Login',
defaults : {
required : true,
labelAlign: 'left'
},
items : [
{
xtype: 'textfield',
name: 'name',
placeholder: 'Kullanici Adi / UserName'
},{
xtype: 'passwordfield',
name: 'password',
placeholder: 'Sifre / Password'
},
{
xtype: 'select',
name : 'language',
label: 'Dil/Language',
options: [
{text: 'Turkce', value: 'turkish'},
{text: 'English', value: 'english'}
]
}
]
}
],
dockedItems :[{
xtype : 'toolbar',
dock : 'bottom',
items : [
{
text: 'Login',
ui:'action',
handler : function(){
Ext.getBody().mask(false, '<div class="demos-loading">Loading…</div>');
Ext.Ajax.request({
url: 'loginUser.jsp',
method: 'post',
params: loginForm.getValues(),
success: function(response, opts) {
x = Ext.decode(response.responseText);
if (x.errorMessage != null)
alert(x.errorMessage);
else {
mainPanel.setCard(dashboard, 'slide');
}
Ext.getBody().unmask();
}
});
}
},
{
text: 'Reset',
handler: function(){
form.reset();
}
}
]
}]
};
if (Ext.platform.isAndroidOS) {
formBase.items.unshift({
xtype: 'component',
styleHtmlContent: true,
html: '<span style="color: red">Forms on Android are currently under development. We are working hard to improve this in upcoming releases.</span>'
});
}
if (Ext.platform.isPhone) {
formBase.fullscreen = true;
} else {
Ext.apply(formBase, {
autoRender: true,
floating: true,
modal: true,
centered: true,
hideOnMaskTap: false,
height: 385,
width: 480
});
}
var form = new Ext.form.FormPanel(formBase);
form.show();
}
}
)
Login.JSP file;
<%
String result;
String loginUsername = request.getParameter("name");
if (null != loginUsername && loginUsername.length() > 0) {
if (loginUsername.equals("name"))
result = "{success:true}";
else
result = "{success:false,errors:{reason:'Login failed.Try again'}}";
} else {
result = "{success:false,errors:{reason:'Login failed.Try again'}}";
}
%>
<%=result %>