cancel
Showing results for 
Search instead for 
Did you mean: 

WCEM:clicking on custom button(Excel Downlaod) giving message "An error occurred; please try again. If the error persists, please contact technical support."

Former Member
0 Kudos

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;

    }

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member193379
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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

  1. c.event.trigger:<>/<>/javax.faces.resource/sap/comp.theme/templates/jquery/lib/jquery-1.4.2.min.js.jsf:54
  2. c.event.trigger:<>/<>/javax.faces.resource/sap/comp.theme/templates/jquery/lib/jquery-1.4.2.min.js.jsf:54
  3. c.event.trigger:<>/<>/javax.faces.resource/sap/comp.theme/templates/jquery/lib/jquery-1.4.2.min.js.jsf:66

(anonymous function):<>/<>/javax.faces.resource/sap/comp.theme/templates/jquery/lib/jquery-1.4.2.min.js.jsf:30

  1. c.extend.each:<>/<>/javax.faces.resource/sap/comp.theme/templates/jquery/lib/jquery-1.4.2.min.js.jsf:24 c.fn.c.each:<>/<>/javax.faces.resource/sap/comp.theme/templates/jquery/lib/jquery-1.4.2.min.js.jsf:66 c.fn.extend.trigger:<>/<>/javax.faces.resource/<>dev/comp.theme/templates/jquery/js/commandButton.js.jsf:31
  2. com.sap.wec.commandButton.submitForm:<>/<>/main/<>HomePage.jsf?wec-appid=<>MAINAPP6&objectID=500000233&page=D61CFFF8E75D48A1B348F315D209EFF9&wec-locale=en_US:48 onclick

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

Former Member
0 Kudos

Hi Hamendra,

After checking few more steps, i think this error is occurring at CommandButton.js file.

Thanks

Subassish

former_member193379
Active Contributor
0 Kudos

Hi Subassish,

If you think that the problem is with java script file them please debug it or to confirm that all is ok from java side then view the log via NWA or directly check in log folder of Netweaver App Server.

Thanks,

Hamendra