?? gbs_serviceinfosubaction.java
字號(hào):
package 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.upload.FormFile;
import COMMON.BaseCommonCheck;
import COMMON.BaseDispatchAction;
import COMMON.MessageList;
import COMMON.ReturnValue;
import COMMON.SystemConstants;
import DataBean.GBS_ServiceInfoList_Bean;
import LOGIC.GBS_ServiceInfosubActionLogic;
/**
* GBS_ServiceInfosubAction extends BaseDispatchAction implements SystemConstants
* created on 29-07-2004
* @author mxx
* @version 1.0
*/
public class GBS_ServiceInfosubAction extends BaseDispatchAction implements SystemConstants {
/**
* method init
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward init( ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
GBS_ServiceInfosubForm thisform = (GBS_ServiceInfosubForm) form;
//get login user info from session
this.setUserInfoFromSession( request, thisform);
GBS_ServiceInfosubActionLogic logic = new GBS_ServiceInfosubActionLogic(this.getDataSource(request));
String title;
String filename;
String seqno = thisform.getSeqno();
//String admin = thisform.getLoginAdminAuthority();
//thisform.setLoginAdminAuthority("3");
if(seqno.equals("")){
thisform.setMethod("insert");
}else {
//Search data
ReturnValue returnValue = logic.getServiceInfosub(seqno);
if ( returnValue.isError() ){
//error occurs
if(returnValue.isBussinessError()){
this.setMessage( returnValue.getMessageList() );
}
}else{
//no error happen ,get data and write to the form
GBS_ServiceInfoList_Bean st =
( GBS_ServiceInfoList_Bean ) returnValue.getDataValue();
if ( st != null ){
thisform.setTitle( st.getTitle() );
thisform.setSeqno( st.getSeqno() );
thisform.setAttachmentfilename( st.getAttachmentfilename() );
thisform.setFdelflag("off");
thisform.setMethod("update");
if(st.getCreateuser().equals(thisform.getLoginUserId())){
thisform.setShowdelbtnflag("1");
}
}
}
}
return (mapping.findForward(nextview));
}
/**
* method update
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward update( ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
GBS_ServiceInfosubForm thisForm = (GBS_ServiceInfosubForm) form;
//get login user info from session
this.setUserInfoFromSession( request, thisForm);
ReturnValue returnValue = new ReturnValue();
MessageList errorMsg = new MessageList();
String flag = thisForm.getFdelflag();
String seqno = thisForm.getSeqno();
String title = thisForm.getTitle();
String updateuser = thisForm.getLoginUserId();
String updatedate = "";
GBS_ServiceInfosubActionLogic logic =
new GBS_ServiceInfosubActionLogic( this.getDataSource(request) );
//input check
errorMsg = inputCheck(thisForm,request);
if (errorMsg.size() > 0) {
//save error to request
this.setMessage( errorMsg );
return (mapping.findForward(nextview));
}
//update Service info
boolean FileDelete = false;
if(flag.equals("on")){
FileDelete = true;
}
returnValue=logic.updateService(seqno,
title,
updatedate,
updateuser,
thisForm.getAttachmentFile(),
FileDelete);
if(returnValue.isError()){
if(returnValue.isBussinessError()){
this.setMessage( returnValue.getMessageList() );
return (mapping.findForward(nextview));
}
}
// forward to sucess
thisForm.setMethod("close");
return (mapping.findForward(nextview));
}
/**
* method delete
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward delete( ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
GBS_ServiceInfosubForm thisform = (GBS_ServiceInfosubForm) form;
//get login user info from session
this.setUserInfoFromSession( request, thisform);
String seqno = thisform.getSeqno();
//delete
GBS_ServiceInfosubActionLogic logic = new GBS_ServiceInfosubActionLogic(
this.getDataSource(request));
logic.deleteBySeqno(seqno);
// forward to sucess
thisform.setMethod("close");
return (mapping.findForward(nextview));
}
/**method insert
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward insert( ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
GBS_ServiceInfosubForm thisForm = (GBS_ServiceInfosubForm) form;
//get login user info from session
this.setUserInfoFromSession( request, thisForm);
ReturnValue returnValue = new ReturnValue();
MessageList errorMsg = new MessageList();
String flag = thisForm.getFdelflag();
String seqno = thisForm.getSeqno();
String title = thisForm.getTitle();
String updateuser = thisForm.getLoginUserId();
String updatedate = "";
GBS_ServiceInfosubActionLogic logic =
new GBS_ServiceInfosubActionLogic( this.getDataSource(request) );
//input check
errorMsg = inputCheck(thisForm,request);
if (errorMsg.size() > 0) {
//save error to request
this.setMessage( errorMsg );
return (mapping.findForward(nextview));
}
boolean FileDelete = false;
if(flag.equals("on")){
FileDelete = true;
}
//insert a new record into Service info
returnValue = logic.insertService( seqno,
title,
updatedate,
updateuser,
thisForm.getAttachmentFile() );
if(returnValue.isError()){
if(returnValue.isBussinessError()){
this.setMessage( returnValue.getMessageList() );
return (mapping.findForward(nextview));
}
}
// forward to sucess
thisForm.setMethod("close");
return (mapping.findForward(nextview));
}
/**
* method inputCheck
* @param requestForm GBS_ServiceInfosubForm
* @param request HttpServletRequest
* @throws Exception
* @return ErrorMessages
*/
private MessageList inputCheck(GBS_ServiceInfosubForm requestForm,
HttpServletRequest request) throws Exception {
//create ErrorMessages to display error message
MessageList messages = new MessageList();
String strTitle = requestForm.getTitle();
FormFile attachmentFile = requestForm.getAttachmentFile();
//Title check
//if (requestForm.getFdelflag().equals("off")){
//Add by Gxk 2004/08/23:add Fdelflag check
if( !requestForm.getFdelflag().equals("on") && attachmentFile != null && requestForm.getAttachmentfilename().equals("") &&
// if( attachmentFile != null && requestForm.getAttachmentfilename().equals("") &&
attachmentFile.getFileName().equals("") &&
BaseCommonCheck.isEmpty(strTitle) ){
messages.setMessage("title", requestForm.getTitle(), "10000016", Integer.MIN_VALUE);
//Delete by Gxk 2004/08/23
// messages.setMessage("attachmentFile", requestForm.getTitle(), "10000016", Integer.MIN_VALUE);
}
if (requestForm.getFdelflag().equals("on") &&
BaseCommonCheck.isEmpty( strTitle )){
messages.setMessage("title", requestForm.getTitle(), "10000009", Integer.MIN_VALUE,
new Object[]{ "Title" }, "Title");
}
//AttachmentFile check
//if(requestForm.getFdelflag().equals("off")){
if((attachmentFile != null && !attachmentFile.getFileName().equals("")) && attachmentFile.getFileSize()==0){
messages.setMessage( "attachmentFile", null, "10000012", Integer.MIN_VALUE,
new Object[]{ "AttachmentFile" }, "AttachmentFile");
}
//}
//AttachmentFile's name check
if(attachmentFile != null && attachmentFile.getFileName().length() > 100){
messages.setMessage("","", "10000018", Integer.MIN_VALUE);
}
return messages;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -