您的位置:首页 > 其它

系统原型结构描述(六)

2008-07-29 09:03 225 查看
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;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: