日期:2014-05-17  浏览次数:20783 次

报销流程输入的值怎么通过struts带回action?
action配置:

package com.lx.action;

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 org.apache.struts.validator.LazyValidatorForm;

import com.lp.base.pojo.LoginUser;
import com.lp.core.LpContext;
import com.lp.core.LpWebContext;
import com.lx.mode.Reimburse;
import com.lx.mode.ReimburseAuditing;
import com.lx.mode.ReimburseDetail;

public class ExamineAction extends DispatchAction {
public ActionForward init(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (((LpWebContext) LpContext.getCurr()).getParams().hasError()) {// 验证错误
return mapping.findForward("defError");

}

LoginUser loginUser = (((LpWebContext) LpContext.getCurr())
.getLoginUser());
java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());

request.setAttribute("userName", loginUser.getUsertruename());
request.setAttribute("date", date);

return mapping.findForward("rimburse");
}

// 报销处理
public ActionForward reimburse(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (((LpWebContext) LpContext.getCurr()).getParams().hasError()) {// 验证错误
return mapping.findForward("defError");

}
LazyValidatorForm dform = (LazyValidatorForm) form;
LoginUser loginUser = (((LpWebContext) LpContext.getCurr())
.getLoginUser());
Reimburse reimburse = new Reimburse();
reimburse.setUSERCODE(loginUser.getUserid());
reimburse.setUNITCODE((String) dform.get("unitcode"));
reimburse.setMoney(Float.parseFloat((String) dform.get("money")));
java.sql.Date date = new java.sql.Date(new java.util.Date().getTime());
reimburse.setReimburseState("0"); // 未审核
reimburse.setReimburseTime(date);
LpContext.getCurr().getPersistentService().beginTransaction();
LpContext.getCurr().getPersistentService().currentSession().save(
reimburse);
// for (int i = 1; i < 4; i++) {
ReimburseDetail rd = new ReimburseDetail();
rd.setWFINSTID(reimburse.getWFINSTID());
rd.setSerialNo(Integer.parseInt((String) dform.get("SerialNo")));
rd.setDetailName((String) dform.get("DetailName"));
rd.setDetailSum(Float.parseFloat((String) dform.get("DetailSum")));
rd.setDetailPrice(Float.parseFloat((String) dform.get("DetailPrice")));
rd.setDetailMoney(Float.parseFloat((String) dform.get("DetailMoney")));
LpContext.getCurr().getPersistentService().currentSession().save(rd);
// }

ReimburseAuditing ra = new ReimburseAuditing();
ra.setFlowID(reimburse.getWFINSTID());
ra.setSTATE("0");
LpContext.getCurr().getPersistentService().currentSession().save(ra);

// LpContext.getCurr().getPersistentService().commitTransaction();
request.setAttribute("userName", loginUser.getUsertruename());
request.setAttribute("date", date);
return mapping.findForward("rimburse");
}

// 报销审核
public ActionForward marklist(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

return mapping.findForward("rimburselist");
}

}
---------------