📄 savepageaction.java~1~
字号:
package com.jdon.cms.events;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.util.*;
import com.jdon.cms.Page;
import com.jdon.cms.PageHandler;
import com.jdon.util.Debug;
import com.jdon.util.UtilValidate;
import org.apache.commons.beanutils.PropertyUtils;
/**
*
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Jdon.com Copyright (c) 2003</p>
* <p>Company: </p>
* @author banq
* @version 1.0
*/
public class SavePageAction extends Action {
public final static String module = SavePageAction.class.getName();
private PageForm pageForm = null;
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response) {
FormBeanUtil.remove(actionMapping, request);
boolean success = false;
this.pageForm = (PageForm) actionForm;
if (!checkErrors(request).isEmpty())
return (actionMapping.findForward("pageError"));
Debug.logVerbose(" copyProperties .. " , module);
PageEvent pageEvent = new PageEvent();
Page page = new Page();
try {
PropertyUtils.copyProperties(page, pageForm);
pageEvent.setPage(page);
pageEvent.setAction(pageForm.getAction());
}
catch (Exception e) {
Debug.logError("copyProperties Error:" + e, module);
}
Debug.logVerbose(" send event to pageHandler .. " , module);
PageHandler pageHandler = new PageHandler();
if (pageHandler.perform(pageEvent)){
Debug.logVerbose("update page success " , module);
return actionMapping.findForward("pageOk");
}else
return actionMapping.findForward("pageError");
}
/**
*
* @param action
* @param request
* @return
*/
private ActionErrors checkErrors(HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
String value = null;
String action = pageForm.getAction();
Debug.logVerbose(" action = " + action, module);
if (UtilValidate.isEmpty(action))
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.action.required"));
if (!action.equals(PageEvent.CREATE)) {
Integer Id = pageForm.getId();
if ((Id == null) || (Id.intValue() == 0))
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("error.id.required"));
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
}
return errors;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -