package com.sample.ext4.simplebook.action;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.sample.ext4.simplebook.bean.Book;
import com.sample.ext4.simplebook.bean.BookType;
import com.sample.ext4.simplebook.biz.BookService;
/**
* 简易图书管理系统Action类
*/
public class BookAction extends DispatchAction{
//创建业务层对象。跳转到书籍类型列表页面
private BookService service = new BookService();
/**
* 跳转到书籍类型列表页面
*/
public ActionForward showBookTypeList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List<BookType> bookTypes = service.getBookTypes();//获取书籍类型列表
request.setAttribute("bookTypes", bookTypes);//将书籍类型列表放到请求中
return mapping.findForward("bookTypeList");//跳转到书籍类型列表页面
}
/**
* 跳转到书籍列表页面
*/
public ActionForward showBookList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List<Book> books = service.getBooks();//获取书籍列表
request.setAttribute("books", books);//将书籍列表放到请求中
return mapping.findForward("bookList"); //跳转到书籍列表页面
}
/**
* 跳转到书籍新增页面
*/
public ActionForward toAddBook(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
List<BookType> bookTypes = service.getBookTypes(); //获取书籍类型列表
request.setAttribute("bookTypes", bookTypes);//将书籍类型列表放到请求中
return mapping.findForward("addBook");//跳转到书籍新增页面
}
/**
* 跳转到书籍修改页面
*/
public ActionForward toModifyBook(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
int bookId = Integer.parseInt(request.getParameter("bookId"));//获取书籍id
List<BookType> bookTypes = service.getBookTypes();//获取书籍类型列表
request.setAttribute("bookTypes", bookTypes);//将书籍类型列表放到请求中
Book book = service.getBook(bookId); //获取指定id的书籍信息
request.setAttribute("book", book);//将书籍信息放到请求中
return mapping.findForward("modifyBook");//跳转到书籍修改页面
}
/**
* 修改书籍信息
*/
public ActionForward modifyBook(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
int bookId = Integer.parseInt(request.getParameter("bookId"));//获取书籍id
String bookName = request.getParameter("bookName");//获取书籍名称
String author = request.getParameter("author");//获取书籍作者
int bookTypeId = Integer.parseInt(request.getParameter("bookTypeId")); //获取类型id
float price = Float.parseFloat(request.getParameter("price"));//获取书籍金额
String brief = request.getParameter("brief");//获取书籍简介
Book book = new Book(); //创建书籍对象
book.setId(bookId);//设置书籍对象id;
book.setBookName(bookName);//设置书籍对象名称信息
book.setAuthor(author);//设置书籍对象作者信息
book.setBookTypeId(bookTypeId);//设置书籍对象类型id信息
book.setPrice(price);//设置书籍对象金额信息;
book.setBrief(brief);//设置书籍对象简介信息
boolean isSuccess = service.updateBook(book);//更新书籍信息
if(isSuccess){//判断更新书籍信息是否成功
return mapping.findForward("toBookList");//更新成功跳转到书籍列表页面
}else{
return mapping.findForward("error");//更新失败跳转到错误页面
}
}
/**
* 新增书籍
* 操作成功后将页面跳转到书籍列表页面
*/
public ActionForward addBook(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String bookName = request.getParameter("bookName");//获取书籍名称
String author = request.getParameter("author");//获取书籍作者
int bookTypeId = Integer.parseInt(request.getParameter("bookTypeId"));//获取类型id
float price = Float.parseFloat(request.getParameter("price"));//获取书籍金额
String brief = request.getParameter("brief");//获取书籍简介
Book book = new Book();//创建书籍对象;
book.setBookName(bookName);//设置书籍对象名称信息
book.setAuthor(author);//设置书籍对象作者信息
book.setBookTypeId(bookTypeId);//设置书籍对象类型id信息
book.setPrice(price);//设置书籍对象金额信息
book.setBrief(brief);//设置书籍对象简介信息
int bookId = service.addBook(book);//新增书籍信息
if(bookId != -1){//判断新增书籍信息是否成功
return mapping.findForward("toBookList");//新增成功跳转到书籍列表页面
}else{
return mapping.findForward("error"); //新增失败跳转到错误页面
}
}
/**
* 新增书籍类型
* 操作成功后将页面跳转到书籍类型列表页面
*/
public ActionForward addBookType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String title = request.getParameter("title"); //获取书籍类型标题
String detail = request.getParameter("detail");//获取书籍类型描述
BookType bookType = new BookType();//创建书籍类型对象
bookType.setTitle(title);//设置书籍类型对象标题信息
bookType.setDetail(detail);//设置书籍类型对象描述信息
int bookTypeId = service.addBookType(bookType);//新增书籍类型
if(bookTypeId != -1){ //判断书籍类型新增是否成功
return mapping.findForward("toBookTypeList");//新增成功则跳转到类型列表
}else{
return mapping.findForward("error"); //新增失败则跳转到错误页面
}
}
/**
* 跳转到书籍类型新增页面
*/
public ActionForward toAddBookType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("addBookType");//跳转到书籍类型列表页面
}
/**
* 跳转到书籍类型修改页面
*/
public ActionForward toModifyBookType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
int bookTypeId = Integer.parseInt(request.getParameter("bookTypeId"));//获取类型id
BookType bookType = service.getBookType(bookTypeId);//获取指定id的书籍类型
request.setAttribute("bookType", bookType);//将书籍类型放入请求中
return mapping.findForward("modifyBookType");//跳转到书籍类型修改页面
}
/**
* 修改书籍类型信息
*/
public ActionForward modifyBookType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
int bookTypeId = Integer.parseInt(request.getParameter("bookTypeId"));//获取类型id
String title = request.getParameter("title");//获取类型标题
String detail = request.getParameter("detail");//获取类型说明
BookType bookType = new BookType();//创建书籍类型对象
bookType.setId(bookTypeId);//设置书籍类型对象的id信息;
bookType.setTitle(title);//设置书籍类型对象的标题信息
bookType.setDetail(detail);//设置书籍类型对象的描述信息
boolean
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是一款基于Java语言的ExtJs框架设计的源码,综合运用HTML, CSS, JavaScript等多种技术,包含2234个文件,涵盖1467个GIF图像、233个HTML页面、120个CSS样式表、77个PNG图片、77个SCSS样式表、64个JavaScript脚本、42个JSP页面、35个JAR库文件、34个JAVA源代码文件。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java语言的ExtJs框架设计源码 (2000个子文件)
BookActionExt.class 8KB
BookDao.class 7KB
BookAction.class 6KB
BookService.class 4KB
HSQLDBStartListener.class 3KB
ExtHelper.class 3KB
FormAction.class 2KB
ExtjsAction.class 2KB
GsonBuilderConfiguratorCustom$2.class 2KB
GsonBuilderConfiguratorCustom$1.class 2KB
Book.class 2KB
ExtFormDirectResult.class 2KB
CharacterEncodingFilter.class 2KB
XstreamTest.class 1KB
ExtjsAction.class 1KB
Person.class 1KB
BookType.class 1KB
DataAction.class 1KB
GsonBuilderConfiguratorCustom.class 1KB
JsonLibTest.class 1KB
Person.class 1KB
Person.class 1KB
XstreamListTest.class 1KB
JsonListTest.class 1KB
MyDBUtil.class 1KB
Person.class 933B
PhoneNumber.class 832B
Product.class 791B
HSQLDBConfig.class 757B
TotalJson.class 753B
PageParam.class 699B
Person.class 657B
Total.class 494B
PhoneNumber.class 467B
.classpath 842B
org.eclipse.wst.common.component 467B
org.eclipse.wst.jsdt.ui.superType.container 49B
ext-sandbox.css 224KB
ext-all-scoped.css 219KB
ext-all.css 200KB
ext-ie-scoped.css 197KB
ext-all-access.css 190KB
ext-ie.css 179KB
ext-standard-scoped.css 150KB
ext-standard.css 138KB
ext-all.css 136KB
ext-all-notheme.css 98KB
xtheme-access.css 40KB
xtheme-blue.css 38KB
xtheme-gray.css 38KB
yourtheme.css 37KB
grid.css 11KB
form.css 10KB
button.css 8KB
panel.css 8KB
tabs.css 7KB
grid.css 6KB
grid.css 6KB
grid.css 6KB
panel-reset.css 6KB
core.css 5KB
my-ext-theme.css 5KB
toolbar.css 5KB
layout.css 5KB
date-picker.css 5KB
tree.css 4KB
menu.css 4KB
tree.css 4KB
form.css 4KB
window.css 3KB
tree.css 3KB
tree.css 3KB
button.css 3KB
toolbar.css 3KB
tabs.css 3KB
date-picker.css 3KB
editor.css 3KB
tabs.css 3KB
resizable.css 3KB
date-picker.css 3KB
date-picker.css 3KB
form.css 3KB
tabs.css 3KB
toolbar.css 3KB
toolbar.css 3KB
qtips.css 3KB
form.css 2KB
button.css 2KB
button.css 2KB
panel.css 2KB
panel.css 2KB
slider.css 2KB
panel.css 2KB
style.css 2KB
window.css 2KB
menu.css 2KB
window.css 2KB
window.css 2KB
core.css 2KB
resizable.css 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
lsx202406
- 粉丝: 2490
- 资源: 5598
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功