on 02-20-2015 8:39 PM
Hi Expert,
I need help.
I created a custom button to download data to an excel sheet. after clicking the button I am getting message
"An error occurred; please try again. If the error persists, please contact technical support.".
I tried debugging WCEM, but it is not even reaching that point.
Your help will be highly appreciated.
here is the code.
BitContentview.XHTML
<wec:commandButton id="bdtexcel" immediate="true" actionListener="#{cc.vch.DownloadBITData}" type="submit" value="#{i18n['invoices.ui.openitems.printSelected']}"/> |
UI-repository.xml
<ViewComponent name="BITContentView" componentHandlerClassName="com.cpr.cprwec.app.comm.module.ebpp.ui.handler.impl.BITDetailViewVCHandler"/>
BITDetailViewVCHnadler.java
package com.cpr.cprwec.app.comm.module.ebpp.ui.handler.impl;
import com.cpr.cprwec.app.comm.module.ebpp.backendobject.interf.EbppBackend;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.faces.context.FacesContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import com.cpr.cprwec.app.comm.module.ebpp.modulemgmt.impl.EbppModuleAccessImpl;
import com.cpr.cprwec.app.comm.module.ebpp.modulemgmt.interf.EbppModuleAccess;
import com.cpr.cprwec.app.comm.module.ebpp.ui.dto.impl.DisputeDataDTOImpl;
import com.cpr.cprwec.app.comm.module.ebpp.ui.dto.impl.OpenItemDTOImpl;
import com.cpr.cprwec.app.comm.module.ebpp.ui.dto.interf.DisputeDataDTO;
import com.cpr.cprwec.app.comm.module.ebpp.ui.dto.interf.OpenItemDTO;
import com.cpr.cprwec.app.comm.module.ebpp.ui.dto.impl.BITDataDTOImpl;
import com.cpr.cprwec.app.comm.module.ebpp.ui.dto.interf.BITDataDTO;
import com.cpr.cprwec.app.comm.module.ebpp.ui.dto.impl.BITDetailDTOImpl;
import com.cpr.cprwec.app.comm.module.ebpp.ui.dto.interf.BITDetailDTO;
import com.sap.wec.app.common.module.common.attachment.businessobject.interf.Attachment;
import com.sap.wec.tc.core.backend.sp.jco.JCoConnection;
import com.sap.wec.tc.core.businessobject.BusinessObjectException;
import com.sap.wec.tc.core.common.exceptions.ApplicationBaseRuntimeException;
import com.sap.wec.tc.core.common.logging.WCFLocation;
import com.sap.wec.tc.core.common.searching.businessobject.impl.GenericSearch;
import com.sap.wec.tc.core.common.searching.businessobject.interf.GenericSearchReturnResultData;
import com.sap.wec.tc.core.common.util.GenericFactory;
import com.sap.wec.tc.core.common.util.Message;
import com.sap.wec.tc.core.common.util.MessageList;
import com.sap.wec.tc.core.common.util.table.Table;
import com.sap.wec.tc.core.common.util.table.TableRow;
import com.sap.wec.tc.core.modulemgmt.ForeignModuleAccess;
import com.sap.wec.tc.core.modulemgmt.ModuleAccess;
import com.sap.wec.tc.core.modulemgmt.exceptions.ModuleInactiveException;
import com.sap.wec.tc.core.modulemgmt.exceptions.ModuleLifecycleException;
import com.sap.wec.tc.core.runtime.WecFrameworkRuntime;
import com.sap.wec.tc.core.runtime.WecSession;
import com.sap.wec.tc.core.runtime.jsf.WecFrameworkRuntimeJSF;
import com.sap.wec.tc.core.runtime.jsf.composition.PageManagerBean;
import com.sap.wec.tc.core.runtime.navigation.NavigationCondition;
import com.sap.wec.tc.core.ui.composition.menu.MenuManager;
import com.sap.wec.tc.core.ui.composition.menu.MenuMetadataException;
import com.sap.wec.tc.core.ui.vc.BuildTime;
import com.sap.wec.tc.core.ui.vc.NavigationParameterBinding;
import com.sap.wec.tc.core.ui.vc.RequestParameterBinding;
import com.sap.wec.tc.core.ui.vc.impl.ViewComponentHandlerBaseImpl;
import com.cpr.cprwec.app.comm.module.ebpp.businessobject.interf.BIT;
import com.cpr.cprwec.app.comm.module.ebpp.businessobject.impl.BITImpl;
public class BITDetailViewVCHandler extends
ViewComponentHandlerBaseImpl<EbppModuleAccess> {
protected static final WCFLocation LOCATION = WCFLocation
.getInstance(BITDetailViewVCHandler.class.getName());
public BITDataDTO bitDataDTO;
public BITDetailDTO bitDetailDTO;
public List<BITDataDTO> BITDataDTOList;
public List<BITDetailDTO> BITDetailDTOList;
public boolean noBITData;
public boolean noBITDetail;
public boolean renderPanel = true;
public boolean isDownloadBITData;
public boolean isDownloadBITDetail;
public boolean downloadStarted=false;
public boolean BITFound =false;
public boolean isBITFound() {
return BITFound;
}
public void setDownloadStarted( boolean downloadStarted ){
this.downloadStarted = downloadStarted;
}
public boolean getDownloadStarted(){
return this.downloadStarted;
}
public void setBITFound(boolean BITFound) {
this.BITFound = BITFound;
}
public String getObjectID() {
return objectID;
}
public void setObjectID(String objectID) {
this.objectID = objectID;
}
public List<BITDataDTO> getBITDataDTOList() {
return BITDataDTOList;
}
public List<BITDetailDTO> getBITDetailDTOList() {
return BITDetailDTOList;
}
public Boolean getNoBITData() {
return noBITData;
}
public Boolean getNoBITDetail() {
return noBITDetail;
}
public Boolean getRenderPanel() {
return renderPanel;
}
private static final int DEFAULT_BUFFER_SIZE = 1024000;
public Attachment attachmentData;
public Attachment getAttachmentData() {
return attachmentData;
}
@RequestParameterBinding(maxLength = 1024)
protected String objectID;
@BuildTime
public String processBuildTime() throws BusinessObjectException {
BIT BIT = null;
noBITData = noBITDetail = false;
renderPanel = true;
if (isLoggedIn()) {
if ( isDownloadBITData == true ){
this.downloadBITDataExcel();
}
else {
this.getModuleAccess().getBITBO().clearMessages();
BIT = this.moduleAccess.getBITBO().getBITFromBackend(objectID);
BITDataDTOList = BIT.getBITDataDTOList();
BITDetailDTOList = BIT.getBITDetailDTOList();
}
MessageList objectData = this.getModuleAccess().getBITBO()
.getMessageList();
if (objectData.size() > 0) {
noBITData = noBITDetail = true;
renderPanel = false;
this.addMessageList(objectData);
}
}
return checkLoginCondition();
}
private boolean isLoggedIn() {
return checkLoginCondition() == null;
}
private String checkLoginCondition() {
NavigationCondition navCondition = getNavigationCondition("login");
if (!navCondition.isFullfiled()) {
navCondition.addToNavigationStack();
return navCondition.getOutcome();
}
return null;
}
public String downloadBITData(){
downloadStarted = true;
isDownloadBITData = true;
downloadBITDataExcel();
return checkLoginCondition();
}
public void downloadBITDataExcel() {
// dummyDebug("downloadBITDataExcel", BITDataDTOList.size(), "", "" );
if (BITDataDTOList.size() > 0) {
try {
attachmentData = this.getModuleAccess().getDownloadBO()
.getBITDataExcel(BITDataDTOList);
if (attachmentData != null) {
FacesContext faces = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) faces
.getExternalContext().getResponse();
response.reset();
response.setContentType(attachmentData
.getAttachmentMimeType());
response.setContentLength(attachmentData
.getAttachmentContent().length);
response.setHeader("Content-disposition",
"attachment;filename="
+ attachmentData.getAttachmentName());
response.setBufferSize(DEFAULT_BUFFER_SIZE);
ServletOutputStream out;
try {
out = response.getOutputStream();
out.write(attachmentData.getAttachmentContent());
out.flush();
faces.responseComplete();
} catch (IOException e) {
throw new ApplicationBaseRuntimeException(
"Problem opening file", e);
} finally {
attachmentData = null;
}
}
} catch (BusinessObjectException e) {
e.printStackTrace();
}
}
isDownloadBITData = false;
}
Hi Subassish,
It won't be easy to understand from the code. Please go to log file and try to find out that what exception is thrown.
As you have mentioned above that in debugging you are not reaching that point, what does it mean?
Thanks,
Hamendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Hamendra for checking the issue.
I am setting up breakpoints in WCEM, tab JAVA EE then from menu RUN->Toggle brekpoints and then debug configuration.
the breakpoints are in several places in handler class BITDetailviewVCHandler class including method downloadBITData.
this method I am calling from BitContentview.XHTML
<wec:commandButton id="bdtexcel" immediate="true" actionListener="#{cc.vch.DownloadBITData}" type="submit" value="#{i18n['invoices.ui.openitems.printSelected']}"/>
When the BIT page is loading the control stops at the breakpoint.
but it is not stopping there when i click the 'Excel Download' button.
How do I get the log file. I am very new to WCEM, please guide me.
I tried to debug the UI using Google chrome. it is giving me the following error.
POST https://<>/<>/<>/<>HomePage.jsf?wec-appid=<>MAINAPP6&wec-locale=en_US 500 (Internal Server Error)
when I expand the node
(anonymous function):<>/<>/javax.faces.resource/sap/comp.theme/templates/jquery/lib/jquery-1.4.2.min.js.jsf:30
Navigated to https://wsapdjd803.<>.ca:<>/<>/main/<>HomePage.jsf?wec-appid=<>MAINAPP6&wec-locale=en_US
Seems to be it is failing somewhere commandButton-related JavaScript functions
Thanks
Subassish
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.