package com.xinyuan.ui;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletContext;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.zkforge.json.simple.Test;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Radiogroup;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;
import com.xinyuan.business.ContactBusiness;
import com.xinyuan.domain.Item;
import com.xinyuan.domain.User;
public class ContactWindow extends Window {
/**
*
*/
private static final long serialVersionUID = -7539822443743284972L;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/*
* 增加用户列表的内容 包括姓名 电话 电子邮件
*/
public void onAdd() {
String name = ((Textbox) getFellow("name")).getValue().trim();
String phone = ((Textbox) getFellow("phone")).getValue().trim();
String email = ((Textbox) getFellow("email")).getValue().trim();
Item item = new Item();
item.setName(name);
item.setPhone(phone);
item.setEmail(email);
ApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext((ServletContext) getDesktop()
.getWebApp().getNativeContext());
ContactBusiness contact = (ContactBusiness) ctx
.getBean("contactBusiness");
User user = (User) this.getAttribute("User");
if (user != null) {
item.setUserId(user.getId());
}
if (contact.addItem(item)) {
try {
Messagebox.show("添加用户成功!", "Success", Messagebox.OK,
Messagebox.INFORMATION);
showList();
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
try {
Messagebox.show("添加用户失败, 请重试!", "Failed", Messagebox.RETRY,
Messagebox.ERROR);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
/*
* 显示所用的用户列表
*/
public void showList() {
Listbox listbox = (Listbox) getFellow("items");
listbox.getItems().clear();
ApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext((ServletContext) getDesktop()
.getWebApp().getNativeContext());
ContactBusiness contact = (ContactBusiness) ctx
.getBean("contactBusiness");
User user = (User) this.getAttribute("User");
List<Item> items = contact.getAllItem(user.getId());
Iterator<Item> it = items.iterator();
while (it.hasNext()) {
Item item = (Item) it.next();
Listitem li = new Listitem();
li.setValue(item);
li.appendChild(new Listcell(item.getName()));
li.appendChild(new Listcell(item.getPhone()));
li.appendChild(new Listcell(item.getEmail()));
listbox.appendChild(li);
}
}
/*
* 删除用户
*/
public void onDelete() {
Listbox listbox = (Listbox) getFellow("items");
Listitem lt = listbox.getSelectedItem();
if (lt == null)
return;
Item item = (Item) lt.getValue();
ApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext((ServletContext) getDesktop()
.getWebApp().getNativeContext());
ContactBusiness contact = (ContactBusiness) ctx
.getBean("contactBusiness");
if (contact.deleteItem(item)) {
try {
Messagebox.show("删除用户成功!", "Success", Messagebox.OK,
Messagebox.INFORMATION);
showList();
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
try {
Messagebox.show("删除用户失败, 请重试!", "Failed", Messagebox.RETRY,
Messagebox.ERROR);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
/*
* 查询用户
*/
public void Select() {
// Textbox idTextbox = (Textbox) this.getFellow("id");
//Textbox nameTextbox = (Textbox) this.getFellow("name");
//Textbox phoneTextbox = (Textbox) this.getFellow("phone");
//Textbox emailTextbox = (Textbox) this.getFellow("email");
Listbox listbox = (Listbox) getFellow("items");
listbox.getItems().clear();
ApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext((ServletContext) getDesktop()
.getWebApp().getNativeContext());
ContactBusiness contact = (ContactBusiness) ctx
.getBean("contactBusiness");
User user = (User) this.getAttribute("User");
// String HQL="from Traffic tc where tc.province like '%"+province+"%'";
String HQL = "from Item item where item.name like '%" + name + "%'";
List<Item> items = contact.findBy(HQL);
Iterator<Item> it = items.iterator();
while (it.hasNext()) {
Item item = (Item) it.next();
Listitem li = new Listitem();
li.setValue(item);
li.appendChild(new Listcell(item.getName()));
li.appendChild(new Listcell(item.getPhone()));
li.appendChild(new Listcell(item.getEmail()));
listbox.appendChild(li);
}
}
/*
* public void onCreate() { ITestLogic testLogic = (ITestLogic)
* SpringFactory .getBeanFactory().getBean("testLogic"); List testList =
* testLogic.find("from Item"); Iterator it = testList.iterator();
* while(it.hasNext()) { Item item = (Item) it.next(); // Long id =
* item.getId(); String name = item.getName(); String phone=item.getPhone();
* String email=item.getEmail();
*
* Listitem listitem = new Listitem(); //listitem.setValue(id);
* listitem.setParent(this);
*
* Listcell nameCell = new Listcell(name); Listcell phoneCell = new
* Listcell(phone.toString()); Listcell emailCell = new
* Listcell(email.toString()); // Listcell moneyCell = new
* Listcell(money.toString()); nameCell.setParent(listitem);
* phoneCell.setParent(listitem); emailCell.setParent(listitem); //
* moneyCell.setParent(listitem); } }
*/
/*
* 修改用户
*/
public void onUpdate() {
Textbox nameTextbox = (Textbox) this.getFellow("name");
Textbox phoneTextbox = (Textbox) this.getFellow("phone");
Textbox emailTextbox = (Textbox) this.getFellow("email");
Item item = new Item();
if (nameTextbox.getValue() == null
|| "".equals(nameTextbox.getValue())) {
throw new WrongValueException(nameTextbox, "用户名不能为空");
}
if (phoneTextbox.getValue() == null
|| "".equals(phoneTextbox.getValue())) {
throw new WrongValueException(phoneTextbox, "电话不能为空");
}
if (emailTextbox.getValue() == null
|| "".equals(emailTextbox.getValue())) {
throw new WrongValueException(emailTextbox, "电话不能为空");
}
item.setName(nameTextbox.getValue());
item.setPhone(phoneTextbox.getValue());
item.setEmail(emailTextbox.getValue());
ApplicationContext ctx = WebApplicationContextUtils
.getRequiredWebApplicationContext((ServletContext) getDesktop()
.getWebApp().getNativeContext());
ContactBusiness contact = (ContactBusiness) ctx
.getBean("contactBusiness");
contact.updateitem(item);
this.detach();
}
/**
* 使得本页面消失
*/
public void onCencel() {
this.detach();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
zk+spring+hibernate整合
共53个文件
class:12个
java:12个
zul:7个
5星 · 超过95%的资源 需积分: 0 67 下载量 61 浏览量
2008-11-18
15:15:34
上传
评论
收藏 2.96MB RAR 举报
温馨提示
数据库是mysql的 都在压缩文件中了 里面有具体的操作步骤。项目是一个zk+spring+hibernate整合
资源推荐
资源详情
资源评论
收起资源包目录
zk+spring+hibernate整合.rar (53个子文件)
zk+spring+hibernate整合
081117173900.sql 1KB
ZK
.project 1KB
.settings
.jsdtscope 500B
org.eclipse.jdt.core.prefs 629B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
.mymetadata 306B
WebRoot
WEB-INF
web.xml 5KB
lib
mysql-connector-java-5.0.6-bin.jar 515KB
spring.jar 2.81MB
classes
com
xinyuan
dao
impl
UserDAOImpl.class 1KB
ItemDAOImpl.class 2KB
ItemDAO.class 638B
UserDAO.class 333B
business
ContactBusiness.class 593B
ContactBusinessImpl.class 3KB
domain
User.class 1KB
User.hbm.xml 900B
Item.hbm.xml 1KB
Item.class 2KB
ui
RegisterWindow.class 2KB
ListTestBean.class 2KB
LoginWindow.class 3KB
ContactWindow.class 6KB
applicationContext.xml 3KB
hibernate.properties 739B
index.jsp 834B
register.zul 1KB
zktext.zul 2KB
3.png 13KB
user.zul 193B
META-INF
MANIFEST.MF 23B
myContact.zul 3KB
update.zul 1KB
password.zul 1KB
login.zul 508B
.myeclipse
src
com
xinyuan
dao
ItemDAO.java 468B
impl
ItemDAOImpl.java 1KB
UserDAOImpl.java 795B
UserDAO.java 246B
business
ContactBusinessImpl.java 2KB
ContactBusiness.java 438B
domain
User.java 822B
Item.java 1KB
User.hbm.xml 900B
Item.hbm.xml 1KB
ui
LoginWindow.java 2KB
RegisterWindow.java 2KB
ListTestBean.java 1KB
ContactWindow.java 7KB
config
applicationContext.xml 3KB
hibernate.properties 739B
.classpath 1KB
共 53 条
- 1
xingyu568
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页