📄 managepaymentaction.java
字号:
package com.longtime.wap.module.cost.web.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.validator.GenericValidator;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.DispatchActionSupport;
import com.longtime.wap.common.web.Page;
import com.longtime.wap.common.web.PageConstant;
import com.longtime.wap.model.Payment;
import com.longtime.wap.module.cost.service.PaymentService;
import com.longtime.wap.module.cost.web.form.PaymentForm;
/**
* 处理消费记录请求
*
* @author chenxq
* @date 2007-11-26
*/
public class ManagePaymentAction extends DispatchActionSupport {
private PaymentService paymentService;
/**
* 注入消费记录服务对象
*
* @param paymentService
* 消费记录服务对象
*/
public void setPaymentService(PaymentService paymentService) {
this.paymentService = paymentService;
}
/**
* 处理获取消费记录列表的请求
*
* @param mapping
* ActionMapping对象
* @param form
* ActionForm对象
* @param request
* HttpServletRequest对象
* @param response
* HttpServletResponse对象
* @return ActionForward对象
* @throws Exception
* 异常对象
*/
public ActionForward listPayment(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
try {
PaymentForm paymentForm = (PaymentForm) form;
Page page = null;
// 获取页码
String pageNumber = request.getParameter(PageConstant.PARA_PAGE);
// 判断页码是否为空
if (GenericValidator.isBlankOrNull(pageNumber)) {
// 若为空或"",则进入第一页,否则则进入提交的页码
if (GenericValidator
.isBlankOrNull(paymentForm.getCurrentPage())) {
page = new Page(1);
} else {
page = new Page(Integer.parseInt(paymentForm
.getCurrentPage()));
}
} else {
page = new Page(Integer.parseInt(pageNumber));
}
request.setAttribute("payments", this.paymentService
.getPayments(page));
request.setAttribute(PageConstant.ATTR_PAGE, page);
} catch (Exception ex) {
ex.printStackTrace();
}
return mapping.findForward("listPayment");
}
/**
* 处理查看消费记录的请求
*
* @param mapping
* ActionMapping对象
* @param form
* ActionForm对象
* @param request
* HttpServletRequest对象
* @param response
* HttpServletResponse对象
* @return ActionForward对象
* @throws Exception
* 异常对象
*/
public ActionForward viewPayment(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
Long id = Long.valueOf(request.getParameter("id"));
Payment obj = this.paymentService.getPaymentById(id);
request.setAttribute("payment", obj);
return mapping.findForward("view");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -