Guest User

Untitled

a guest
Jul 25th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. Application.Login = Ext.extend(Ext.Container, {
  2. constructor: function(config) {
  3. var username = new Ext.form.TextField();
  4. var password = new Ext.form.TextField();
  5. var loginButton = new Ext.Button({
  6. text : "Login",
  7. listeners : {
  8. click : function () {
  9. Ext.Ajax.request({
  10. url: 'service/login',
  11. jsonData : { "username" : username.getValue(), "password" : password.getValue() },
  12. success:function(response, options) {
  13. jsonObj = Ext.util.JSON.decode(response.responseText);
  14. if (jsonObj.success) {
  15. Ext.Msg.alert('Status', 'Login Successful!');
  16. } else {
  17. Ext.Msg.alert('Login Failed!', jsonObj.errors.reason);
  18. }
  19. },
  20. failure:function(response, options) {
  21. Ext.Msg.alert('Server error');
  22. }
  23. })
  24. }
  25. }
  26. });
  27. config = Ext.apply({
  28. layout: "column",
  29. items:[
  30. {
  31. columnWidth: .5
  32. },
  33. {
  34. items : username,
  35. columnWidth : .2
  36. },
  37. {
  38. items : password,
  39. columnWidth : .2
  40. },
  41. {
  42. items : loginButton,
  43. columnWidth : .1,
  44. layout : 'fit'
  45. }
  46. ]
  47. }, config);
  48. Application.Login.superclass.constructor.call(this, config);
  49. }
  50. });
Add Comment
Please, Sign In to add comment