81,122
社区成员




net.newxy.struts_faces.DispatchAction继承自struts的org.apache.struts.actions.DispatchAction
二、net.newxy.struts_faces.DispatchAction的重要方法
1、getActionForward
public ActionForward getActionForward(ActionMapping actionMapping,HttpServletRequest httpServletRequest){
String frwd=httpServletRequest.getParameter("_frwd");
if(frwd!=null && frwd.trim().length()>0)
return actionMapping.findForward(frwd);
else{
if(actionMapping.getInputForward().getPath()!=null)
return actionMapping.getInputForward();
else{
httpServletRequest.setAttribute("message",net.newxy.cfg.Message.getMessage("errors.path")+";please give a forward for action");
return actionMapping.findForward("error");
}
}
}
2、find
public ActionForward find(ActionMapping actionMapping, ActionForm actionForm,
HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception{
......
return getActionForward(actionMapping,httpServletRequest);
}
public ActionForward update(ActionMapping actionMapping, ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws Exception{
......
net.newxy.struts_faces.FormBean form=(net.newxy.struts_faces.FormBean)actionForm;
try{
Object dto=form.getDto();
IFacade ifacade=IFacadeFactory.getFacade(httpServletRequest.getParameter("_dao"), httpServletRequest.getLocale());
Object result=ifacade.update(dto);
......
}catch(Exception e){
......
}
......
return getActionForward(actionMapping,httpServletRequest);
}
public ActionForward remove(ActionMapping actionMapping, ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws Exception{
......
String index=httpServletRequest.getParameter("_index");
try{
IFacade ifacade=IFacadeFactory.getFacade(httpServletRequest.getParameter("_dao"), httpServletRequest.getLocale());
if (index != null) {
net.newxy.util.FormBeanUtils.remove(ifacade, form, index);
} else
net.newxy.util.FormBeanUtils.remove(ifacade, form);
}catch(Exception e){
httpServletRequest.setAttribute("error",e.getMessage());
return actionMapping.findForward("error");
}
......
return getActionForward(actionMapping,httpServletRequest);
}
5、edit
public ActionForward edit(ActionMapping actionMapping, ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws Exception{
......
net.newxy.struts_faces.FormBean form=(net.newxy.struts_faces.FormBean)actionForm;
String _index=httpServletRequest.getParameter("_index");
if(_index==null)
_index=form.get_index();
if(_index!=null)
form.setForm(_index);
......
return getActionForward(actionMapping,httpServletRequest);
}