?? paymentlistaction.java
字號:
package com.longtime.wap.module.front.web.action;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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 com.longtime.wap.common.WapConstant;
import com.longtime.wap.common.web.Page;
import com.longtime.wap.common.web.PageConstant;
import com.longtime.wap.frame.common.UserSessionVO;
import com.longtime.wap.model.Payment;
import com.longtime.wap.model.UncommandWord;
import com.longtime.wap.module.front.common.FrontConstant;
import com.longtime.wap.module.front.service.FrontService;
/**
* 消費列表請求
*
* @author bulc
* @date Nov 19, 2007
*/
public class PaymentListAction extends FrontBaseAction {
private static final Log LOGGER = LogFactory
.getLog(PaymentListAction.class);
private FrontService frontService;
/**
* 注入服務(wù)對象
*
* @param frontService
* 設(shè)置服務(wù)對象
*/
public void setFrontService(FrontService frontService) {
this.frontService = frontService;
}
/**
*
* @param mapping
* ActionMapping對象
* @param form
* ActionForm對象
* @param request
* HttpServletRequest對象
* @param response
* HttpServletResponse對象
* @return ActionForward對象
* @throws Exception
* 異常對象
*/
public ActionForward listUserPayment(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
try {
Page page = null;
String pageNumber = request.getParameter(PageConstant.PARA_PAGE);
if (GenericValidator.isBlankOrNull(pageNumber)) {
page = new Page(1);
} else {
page = new Page(Integer.parseInt(pageNumber));
}
UserSessionVO usVo = (UserSessionVO) request.getSession()
.getAttribute(WapConstant.USER_SESSION);
request.setAttribute(FrontConstant.USER_PAYMENTS_LIST, this
.filtPaymentContent(usVo.getUserId(), page));
request.setAttribute(PageConstant.ATTR_PAGE, page);
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
super.setHeader(request, frontService);
super.setLeft(request, frontService);
return mapping.findForward("userPaymentList");
}
/**
*
* @param userId
* 用戶id對象
* @param page
* 分頁對象
* @return 消費列表
*/
@SuppressWarnings("unchecked")
protected List filtPaymentContent(Long userId, Page page) {
List returnList = new ArrayList();
List payments = frontService.getPaymentsByUserId(userId, page);
try {
for (int i = 0; i < payments.size(); i++) {
Payment pay = (Payment) payments.get(i);
pay = this.filtPaymentContent(pay);
if ((pay.getInformationTitle().trim()).length() != 0) {
returnList.add(pay);
}
}
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
return returnList;
}
/**
* @param pay 消費對象
* @return 消費對象
*/
protected Payment filtPaymentContent(Payment pay) {
try {
List ucw = this.frontService.getUncommandWords();
Iterator it = ucw.iterator();
while (it.hasNext()) {
UncommandWord ucWord = (UncommandWord) it.next();
if (!GenericValidator.isBlankOrNull(
pay.getInformationTitle())) {
if (pay.getInformationTitle().contains(ucWord.getWord())) {
StringBuilder replaceWord = new StringBuilder();
for (int i = 0; i < ucWord.getWord().length(); i++) {
replaceWord.append("*");
}
pay.setInformationTitle(pay.getInformationTitle()
.replaceAll(ucWord.getWord(),
replaceWord.toString()));
}
}
}
} catch (Exception ex) {
LOGGER.error(ex);
ex.printStackTrace();
}
return pay;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -