Ext.onReady(function() { Ext.QuickTips.init(); Ext.form.Field.prototype.msgTarget = 'side'; var loginForm = new Ext.FormPanel( { renderTo : document.body, url: 'json/login', title : 'Login HR Recruiting System', bodyStyle : 'padding:5px 5px 0;', frame : true, labelAlign : 'right', labelWidth : 75, width : 300, html : '<div align="right" style="width:94%"><a href="">Forget your password?</a></div>', defaultType : 'textfield', defaults : { width : 180 }, items : [ { fieldLabel : 'Username', name : 'user.loginName', allowBlank : false }, { fieldLabel : 'Password', name : 'user.password', inputType : 'password', allowBlank : false }], buttons : [ { text : 'Login', handler : function login() { if (loginForm.form.isValid()) { Ext.MessageBox.wait('Passing information, Wait.. '); loginForm.form.submit({ success: function(form, action) { Ext.Msg.hide(); Ext.Msg.alert('Success', 'It worked'); }, failure: function(form, action){ Ext.Msg.hide(); Ext.Msg.alert('Warning', 'Warning'); } }); } } }, { text : 'Reset', handler : function reset() { loginForm.form.reset(); } }] }); loginForm.getEl().center(); });
package com.test.hrrs.action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.test.hrrs.entity.User;
import com.test.hrrs.service.UserService;
import com.googlecode.jsonplugin.annotations.JSON;
/**
* @author Clay Zhong, zjclay@gmail.com
*
* @date Jul 4, 2009
*/
@Scope("prototype")
@Controller
public class UserAction extends BaseAction {
private static final long serialVersionUID = 1L;
@Autowired
private UserService userService;
private User user;
private Boolean success;
public String login() {
User existUser = userService.getByName(user.getLoginName());
if ((existUser != null) && existUser.getPassword().trim().equals(user.getPassword().trim())) {
success = true;
} else {
success = false;
}
return JSON_RESULE;
}
public String create() {
User user = new User();
user.setLoginName("clay");
user.setEmail("clayz@126.com");
user.setPassword("password");
userService.create(user);
return SUCCESS;
}
public String view() {
user = userService.get(user.getId());
if (user != null) {
System.out.println(user.getEmail());
}
return "view";
}
@JSON(serialize = false)
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
}