系统原型结构描述(六)

 


globalMessages_en_US.properties
globalMessages_zh_CN.properties

HelloWorld = HelloWorld


FindEditAction_en_US.properties
FindEditAction_zh_CN.properties

Find.Title = Find

IndexEditProcessAction-validation.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE validators PUBLIC
 "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
 "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
 <field name="name">
  <field-validator type="requiredstring">
   <param name="trim">true</param>
   <message>Please input name!</message>
  </field-validator>
 </field>
 <field name="author">
  <field-validator type="requiredstring">
   <param name="trim">true</param>
   <message>Please input author!</message>
  </field-validator>
 </field>
</validators>
 

DelEditProcessAction.java

package com.test.action.edit;

import com.opensymphony.xwork2.ActionSupport;
import com.test.logic.service.BookService;

public class DelEditProcessAction extends ActionSupport {
 private BookService bookService = null;
 public int id = 0;
 
 public int getId() {
  return id;
 }
 public void setId(int id) {
  this.id = id;
 }
 public BookService getBookService() {
  return bookService;
 }
 public void setBookService(BookService bookService) {
  this.bookService = bookService;
 }
 public String execute() {
  String result = ERROR;
  
  if(id > 0) {
   this.bookService.deleteBookById(id);
   result = SUCCESS;
  } else {
   result = ERROR;
  }
  return result;
 }
}


FindEditAction.java

package com.test.action.edit;

import com.opensymphony.xwork2.ActionSupport;

public class FindEditAction extends ActionSupport {

 public String execute() {
  
  return SUCCESS;
 }
}


FindEditProcessAction.java

package com.test.action.edit;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.test.logic.service.BookService;

public class FindEditProcessAction extends ActionSupport {
 private BookService bookService = null;
 public String key = "";
 public List list = null;
 
 public String getKey() {
  return key;
 }
 public void setKey(String key) {
  this.key = key;
 }
 public BookService getBookService() {
  return bookService;
 }
 public void setBookService(BookService bookService) {
  this.bookService = bookService;
 }
 public String execute() {
  String result = ERROR;
  
  String tmp;
  
  tmp = key.trim();
  if(tmp.length() > 0) {
   list = this.bookService.findBooks(key);
   result = SUCCESS;
  }
  
  return result;
 }
}


IndexEditAction.java


package com.test.action.edit;

import org.apache.log4j.Logger;

import com.opensymphony.xwork2.ActionSupport;
import com.test.domain.Book;
import com.test.logic.service.BookService;

public class IndexEditAction extends ActionSupport {
 static Logger logger  = Logger.getLogger(IndexEditAction.class);
 private BookService bookService = null;
 public int id = 0;
 public String name = "";
 public String author = "";
 public String summary = "";
 
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public String getAuthor() {
  return author;
 }
 public void setAuthor(String author) {
  this.author = author;
 }
 public String getSummary() {
  return summary;
 }
 public void setSummary(String summary) {
  this.summary = summary;
 }
 public int getId() {
  return id;
 }
 public void setId(int id) {
  this.id = id;
 }
 public BookService getBookService() {
  return bookService;
 }
 public void setBookService(BookService bookService) {
  this.bookService = bookService;
 }
 public String execute() {
  
  
  logger.debug("IndexEditAction executing ...");
  logger.debug("id : " + id);
  
  if(id > 0) {
   Book book = this.bookService.getBookById(id);
   if(book != null) {
    this.id = book.getId();
    this.name = book.getName();
    this.author = book.getAuthor();
    this.summary = book.getSummary();
   }
  }
  
  return SUCCESS;
 }
}

IndexEditProcessAction.java

package com.test.action.edit;

import com.opensymphony.xwork2.ActionSupport;
import com.test.domain.Book;
import com.test.logic.service.BookService;

public class IndexEditProcessAction extends ActionSupport {
 private BookService bookService = null;
 public int id = 0;
 public String name = "";
 public String author = "";
 public String summary = "";
 
 public int getId() {
  return id;
 }
 public void setId(int id) {
  this.id = id;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public String getAuthor() {
  return author;
 }
 public void setAuthor(String author) {
  this.author = author;
 }
 public String getSummary() {
  return summary;
 }
 public void setSummary(String summary) {
  this.summary = summary;
 }
 public BookService getBookService() {
  return bookService;
 }
 public void setBookService(BookService bookService) {
  this.bookService = bookService;
 }
 public String execute() {
  String result = ERROR;
  Book book = new Book();
  
  book.setId(id);
  book.setName(name);
  book.setAuthor(author);
  book.setSummary(summary);
  try {
   this.bookService.save(book);
   result = SUCCESS;
  } catch (Exception e) {
   e.printStackTrace();
   result = ERROR;
  }
  return result;
 }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值