📄 savepageaction.java
字号:
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.util.Debug;
import com.jdon.util.UtilValidate;
import org.apache.commons.beanutils.PropertyUtils;
import com.jdon.controller.ServiceProxyHandler;
import com.jdon.controller.events.EventUtil;
/**
*
* <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();
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response) {
FormBeanUtil.remove(actionMapping, request);
boolean success = false;
PageForm pageForm = (PageForm) actionForm;
if (!checkErrors(pageForm, request).isEmpty())
return (actionMapping.findForward("pageError"));
Debug.logVerbose(" copyProperties .. ", module);
PageEvent pageEvent = new PageEvent(module, EventUtil.actionTransfer(pageForm.getAction()));
Page page = new Page();
try {
PropertyUtils.copyProperties(page, pageForm);
pageEvent.setPage(page);
} 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");
**/
Debug.logVerbose(" send event to pageHandler .. ", module);
ServiceProxyHandler.perform(pageEvent);
if (pageEvent.getErrors() == null) {
Debug.logVerbose("update page success ", module);
return actionMapping.findForward("pageOk");
} else
return actionMapping.findForward("pageError");
}
/**
*
* @param action
* @param request
* @return
*/
private ActionErrors checkErrors(PageForm pageForm,
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(EventUtil.CREATE_STR)) {
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 + -