📄 savezkkaction.java
字号:
package org.helpsoft.actions;
import java.text.SimpleDateFormat;
import javax.servlet.*;
import javax.servlet.http.*;
import org.helpsoft.servicelocator.*;
import org.helpsoft.session.AssociatorManageService;
import org.apache.struts.action.*;
import org.helpsoft.forms.*;
import com.helpsoft.util.log.*;
import com.helpsoft.util.*;
import com.helpsoft.util.genelv.struts.GenericAction;
import org.helpsoft.session.*;
import org.helpsoft.entity.zkk.*;
import com.helpsoft.Constants;
import org.helpsoft.forms.ZkkForm;
/**
* Implementation of <strong>Action</strong>
*
* @author cao guangxin - www.relationinfo.com
* @struts.action path="/saveZkk"
* type="org.helpsoft.actions.SaveZkkAction"
* name="zkkForm"
* scope="request"
* input="/zkk.jsp"
* @struts.action-forward name="success" path="/initZkkSearch.do"
*/
public class SaveZkkAction extends ServiceAction {
private transient Logger log = LogService.getLogger(this.getClass());
/**
* Performs an action.
*
* @param mapping The ActionMapping used to select this instance
* @param form The optional ActionForm bean for this request (if any)
* @param request The optional ActionForm bean for this request (if any)
* @param response The HTTP response we are creating
* @return describes where and how control should be forwarded, or <code>null</code> if the response has already
* been completed
* @throws Exception in case of an error
*/
public ActionForward doPerform(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
log.info("start doPerform");
HttpSession session = request.getSession();
ZkkForm subform = (ZkkForm) form;
String hykbm = subform.getHykbm();
if (hykbm != null && (hykbm.equalsIgnoreCase("null") || hykbm.length() < 1)) {
hykbm = null;
subform.setHykbm(null);
}
org.helpsoft.session.AssociatorManageService facade = getAssociatorManageService();
// Was this transaction cancelled?
if (isCancelled(request)) {
if (mapping.getAttribute() != null) {
session.removeAttribute(mapping.getAttribute());
}
return (mapping.findForward("success"));
}
try {
// Retrieve the information
ZkkData data = new ZkkData();
PropertyUtilsExt.copyProperties(data, subform);
// Save to database..
if ("new".equals(subform.getMode())) {
if (request.getParameter("submit") != null) {
facade.addZkk(data);
}
}
else {
if (request.getParameter("submit") != null) {
facade.saveZkk(data);
}
else if (request.getParameter(Constants.SUBMIT_NO_VALIDATION) != null) {
facade.deleteZkk(data.getHykbm());
}
}
}
catch (Throwable t) {
log.error("SaveZkkAction :", t);
throw new Exception("SaveZkkAction :", t);
}
// Remove the obsolete form bean
if (mapping.getAttribute() != null) {
if ("request".equals(mapping.getScope())) {
request.removeAttribute(mapping.getAttribute());
}
else {
session.removeAttribute(mapping.getAttribute());
}
}
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -