?? gbs_presentationsubaction.java
字號:
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_Presentation_stBean;
import LOGIC.GBS_PresentationsubActionLogic;
/**
* GBS_PresentationsubAction extends BaseDispatchAction implements SystemConstants
* created on 11-08-2004
* @author mxx
* @version 1.0
*/
public class GBS_PresentationsubAction 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_PresentationsubForm thisForm = (GBS_PresentationsubForm) form;
// get login user info from session
this.setUserInfoFromSession( request, thisForm);
GBS_PresentationsubActionLogic logic = new GBS_PresentationsubActionLogic(this.getDataSource(request));
ReturnValue returnValue = new ReturnValue();
//MessageList errorMsg = new MessageList();
GBS_Presentation_stBean Presentation_st = new GBS_Presentation_stBean();
String customerId = thisForm.getCustomerId();
String rfpNo = thisForm.getRfpNo();
String lineNo = thisForm.getLineNo();
String fileName;
if(lineNo.equals("")){
thisForm.setMethod("insert");
}else{
returnValue = logic.getPresentationByKey(customerId,rfpNo,lineNo);
//errorMsg = returnValue.getMessageList();
if ( returnValue.isError()){
if(returnValue.isBussinessError()){
this.setMessage( returnValue.getMessageList() );
//return (mapping.findForward(nextview));
}
}
Presentation_st = (GBS_Presentation_stBean) returnValue.getDataValue();
thisForm.setCustomerId(Presentation_st.getCustomerId());
thisForm.setRfpNo(Presentation_st.getRfpNo());
thisForm.setLineNo(Presentation_st.getLineNo());
thisForm.setTitle(Presentation_st.getTitle());
thisForm.setPresentationDate(Presentation_st.getPresentationDate());
thisForm.setPresentationBy(Presentation_st.getPresentationBy());
thisForm.setListener(Presentation_st.getListener());
thisForm.setAttachmentfilename(Presentation_st.getAttachmentFileName());
thisForm.setDelFlag("off");
thisForm.setMethod("update");
}
//
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_PresentationsubForm thisForm = (GBS_PresentationsubForm) form;
//get login user info from session
this.setUserInfoFromSession(request, thisForm);
GBS_PresentationsubActionLogic logic = new GBS_PresentationsubActionLogic(this.getDataSource(request));
//MessageList errorMsg = new MessageList();
String strCustomerId = thisForm.getCustomerId();
String strRfpNo = thisForm.getRfpNo();
String strLineNo = thisForm.getLineNo();
String strTitle = thisForm.getTitle();
String strPresentationBy = thisForm.getPresentationBy();
String strPresentationDate = BaseCommonCheck.convertDateToYYYYMMDD(thisForm.getPresentationDate());
String strListener = thisForm.getListener();
String strCreateUser = thisForm.getLoginUserId();
String flag = thisForm.getDelFlag();
//input check
MessageList errorMsg = new MessageList();
errorMsg = inputCheck(thisForm, request);
if (errorMsg.size() > 0) {
//save error to request
this.setMessage(errorMsg);
return (mapping.findForward(nextview));
}
//insert a new record into Presentation
ReturnValue returnValue =
logic.insertPresentation(
strCustomerId,
strRfpNo,
strListener,
strTitle,
strPresentationDate,
strPresentationBy,
strCreateUser,
thisForm.getAttachmentFile());
if (returnValue.isError()) {
if (returnValue.isBussinessError()) {
this.setMessage(returnValue.getMessageList());
//return (mapping.findForward(nextview));
}
}
int iLineNo = ((Integer) returnValue.getDataValue()).intValue();
if (iLineNo > 0) {
strLineNo = String.valueOf(iLineNo);
}
// forward to sucess
thisForm.setMethod("close");
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_PresentationsubForm thisForm = (GBS_PresentationsubForm) form;
//get login user info from session
this.setUserInfoFromSession( request, thisForm);
//MessageList errorMsg = new MessageList();
ReturnValue returnValue = new ReturnValue();
GBS_PresentationsubActionLogic logic = new GBS_PresentationsubActionLogic(
this.getDataSource(request));
String strCustomerId = thisForm.getCustomerId();
String strRfpNo = thisForm.getRfpNo();
String strLineNo = thisForm.getLineNo();
String strTitle = thisForm.getTitle();
String strPresentationDate = BaseCommonCheck.convertDateToYYYYMMDD(thisForm.getPresentationDate());
String strPresentationBy = thisForm.getPresentationBy();
String strListener = thisForm.getListener();
String strUpdateUser = thisForm.getLoginUserId();
String flag = thisForm.getDelFlag();
FormFile AttachmentFile = thisForm.getAttachmentFile();
boolean FileDelete = false;
//input check
MessageList errorMsg = new MessageList();
errorMsg = inputCheck(thisForm, request);
if (errorMsg.size() > 0) {
//save error to request
this.setMessage( errorMsg );
return (mapping.findForward(nextview));
}
//update Presentation
//if the flag=1,then delete the AttachmentFile
if(flag.equals("on")){
FileDelete = true;
}
returnValue = logic.updatePresentation( strCustomerId,
strRfpNo,
strLineNo,
strTitle,
strPresentationDate,
strPresentationBy,
strListener,
strUpdateUser,
thisForm.getAttachmentFile(),
FileDelete );
if ( returnValue.isError()){
if( returnValue.isBussinessError() ){
this.setMessage( returnValue.getMessageList() );
//return (mapping.findForward(nextview));
}
}
int iLineNo = ((Integer) returnValue.getDataValue()).intValue();
if ( iLineNo > 0 ){
strLineNo = String.valueOf(iLineNo);
}
// 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_PresentationsubForm thisForm = (GBS_PresentationsubForm) form;
// get login user info from session
this.setUserInfoFromSession( request, thisForm);
//MessageList errorMsg = new MessageList();
ReturnValue returnValue = new ReturnValue();
GBS_PresentationsubActionLogic logic = new GBS_PresentationsubActionLogic(
this.getDataSource(request));
String strCustomerId = thisForm.getCustomerId();
String strRfpNo = thisForm.getRfpNo();
String strLineNo = thisForm.getLineNo();
returnValue = logic.deletePresentation(strCustomerId,strRfpNo,strLineNo);
thisForm.setMethod("close");
return (mapping.findForward(nextview));
}
/**
* method inputCheck
* @param requestForm GBS_PresentationsubForm
* @param request HttpServletRequest
* @throws Exception
* @return ErrorMessages
*/
private MessageList inputCheck(GBS_PresentationsubForm requestForm,
HttpServletRequest request) throws Exception {
//create ErrorMessages to display error message
MessageList messages = new MessageList();
String presentationDate = requestForm.getPresentationDate();
FormFile AttachmentFile = requestForm.getAttachmentFile();
if (BaseCommonCheck.isEmpty(requestForm.getTitle())) {
messages.setMessage("title", requestForm.getTitle(), "10000009", Integer.MIN_VALUE,
new Object[]{ "Title" }, "Title");
}
//Presentation Date check
if ((!presentationDate.equals(""))&&(!BaseCommonCheck.isDateType(presentationDate))) {
messages.setMessage("presentationDate", requestForm.getPresentationDate(), "90000025", Integer.MIN_VALUE,
new Object[]{ "Presentation Date" }, "Presentation Date");
}
//check the file
//if(requestForm.getDelFlag().equals("off")){
if((AttachmentFile != null && !AttachmentFile.getFileName().equals("")) && AttachmentFile.getFileSize()==0){
//update by YM 20040823 start
//this.setMessage( "attachmentFile", null, "10000012", Integer.MIN_VALUE,
//new Object[]{ "AttachmentFile" }, "AttachmentFile");
messages.setMessage( "attachmentFile", null, "10000012", Integer.MIN_VALUE,
new Object[]{ "AttachmentFile" }, "AttachmentFile");
//update by YM 20040823 end
}
//}
//AttachmentFile's name check
if(AttachmentFile != null && AttachmentFile.getFileName().length() > 100){
messages.setMessage("","", "10000018", Integer.MIN_VALUE);
}
return messages;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -