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;
}
}
分享到:
相关推荐
ext+struts+spring图书管理的小例子 欢迎下载
EXT 结合struts2,用json方式与ACTION通信,非常经典的入门例子! 里面对ext.extend用的很好!
Ext+struts Ext学生管理系统 Ext与后台交互 Ext与数据库交互《深入浅出》中的最后一个例子
ext3 + struts2 + spring +hibernate做的例子 本例子有两个注意下载
一个基于Ext+Struts2+spring实现的级联分页示例程序源码例子
ext3 + struts2 + spring +hibernate做的例子 共分两个
ext 树 gridpanel 分页 ,文件上传, tabpanel ... 的一些例子 刚学的时候做的..只要加上Ext2.0的包就可以直接运行
EXt3.0+struts2+json小例子 实现增删改查 基本功能 ,以功能简单实现为主 对ext的常用组件的使用,也存在一些细节上的小问题 如果有兴趣可以自己去解决 这便用的oracle做测试用的 ,你也可以改成,模拟数据测试
struts2+extjs2的完整例子。
内含 ext+dwr+freemark+jasperreort+ireport+echance+oscache+velocite等技术 展示例子:http://zz563143188.iteye.com/blog/1462413 若要下载chm格式请到http://user.qzone.qq.com/563143188 程序源码下载地址10MB...
Ext2.0+struts2+spring2.5+ibatis2 结合的例子
Extjs Tree + JSON + Struts2 例子
ext2.1+struts2.0+spring2.5+jdbc+json做的一个小例子
ext的一个增删改查的例子,用的是Hibernate+Spring+Struts2
一个简单的Myeclipse+Struts开发登陆的JSP例子
为了满足学习新技术的朋友们,自己搭建了一个struts2+spring2.5+jdbc+ext+json框架的实例。
网上有些这样的例子,但是下了几个都没有跑起来,哎,希望那些发文章的人要发就发全的,别发个半生不熟的。 现在自己整理了一个Struts2+ExtJS2实现文异步文件上传,没法上传图片无法看到效果,直接上源码吧。
eclipse下EXTJS4+STRUTS2+JAVA增删改查的完整例子!供需要的朋友参考
使用ext2.2 struts2集成生成的一棵树,主要是对struts2返回json数据进行一些处理,树使用ext本身自带的例子