0 Replies Latest reply on Nov 27, 2018 6:19 AM by 3575515

    After clicking on the export button, we get the error when we clicking any button on web page.

    3575515

      When we run export to excel button and then we pushed any button on same web page,we got the following error.

       

      Developer Mode Error: Stale Data

      JavaScript enabled browser required.The requested page contains stale data. This error could have been caused through the use of the browser's navigation buttons (the browser Back button, for example). If the browser's navigation buttons were not used, this error could have been caused by coding mistakes in application code. Please check Supporting the Browser Back Button developer guide - View Object Primary Key Comparison section to review the primary causes of this error and correct the coding mistakes. Cause:The number of displayed records, 4, exceeds the actual number of records, 0, in view object BakimAM.SearchResultsVO1. Some of the displayed records may have been deleted.To proceed, please select the Home link at the top of the application page to return to the main menu. Then, access this page again using the application's navigation controls (menu, links, and so on) instead of using the browser's navigation controls like Back and Forward.

       

       

      We tried to refresh web page when we pushed export to excel button, but we failed to fix the error.We are waiting for your help to solve our mistake.

       

      Our source code is as follows.

       

       

      public class AramaCO extends OAControllerImpl

      {

        public static final String RCS_ID="$Header$";

        public static final boolean RCS_ID_RECORDED =

              VersionInfo.recordClassVersion(RCS_ID, "%packagename%");    

       

        public void processRequest(OAPageContext pageContext, OAWebBean webBean)

        {

            super.processRequest(pageContext, webBean);

            BakimAMImpl bakimAM = (BakimAMImpl) pageContext.getApplicationModule(webBean);

            bakimAM.initSearchVO();

            bakimAM.initResultsVO();

            OATableBean table = (OATableBean)webBean.findIndexedChildRecursive("SearchResultsVO1");

            OAMessageStyledTextBean job = (OAMessageStyledTextBean)table.findIndexedChildRecursive("BaNumber1");

            System.out.println("-*-*-*-*-*-*-*-*  " + job.getValue(pageContext));

            OADataBoundValueViewObject cssjob = new OADataBoundValueViewObject(job,"CssType");

            job.setAttributeValue(oracle.cabo.ui.UIConstants.STYLE_CLASS_ATTR, cssjob);  

            try{   

                if(pageContext.getParameter("pbanumber").length() > 5 ){

                    OAMessageTextInputBean textBean = (OAMessageTextInputBean)webBean.findChildRecursive("BaNumber");

                    textBean.setValue(pageContext, pageContext.getParameter("pbanumber"));

                }

            }catch(NullPointerException npe){

                npe.printStackTrace();

            }

        }

       

        public void processFormRequest(OAPageContext pageContext, OAWebBean webBean){

            super.processFormRequest(pageContext, webBean);

            BakimAMImpl bakimAM = (BakimAMImpl) pageContext.getApplicationModule(webBean);

            String event = pageContext.getParameter(EVENT_PARAM);

              

            if("xClear".equals(event)){

                bakimAM.initSearchVO();

                bakimAM.initResultsVO();

            }

            if("xSearch".equals(event)){

                //pageContext.putDialogMessage(new OAException("Arama",OAException.CONFIRMATION));

                bakimAM.search();

            }

            if("xNewRecord".equals(event)){

                HashMap params = new HashMap(1);

                params.put("pFromPage", "YENIKAYITARAMAPG");

                String targetPage = "OA.jsp?page=/xxkrl/oracle/apps/xxkrl/ba/webui/YeniKayitPG";

                pageContext.forwardImmediately(targetPage, null, (byte)0, null,params, true, "Y");

            }

            if("xLines".equals(event)){

                String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);

                Row currentRow = bakimAM.findRowByRef(rowReference);

                HashMap params = new HashMap(3);

               // params.put("pLineId", pageContext.getParameter("pLineId"));

                params.put("pHeaderId", currentRow.getAttribute("HeaderId").toString());

                params.put("pBaNumber", currentRow.getAttribute("BaNumber").toString());

                params.put("pFromPage", "SATIRLAR");

                String targetPage = "OA.jsp?page=/xxkrl/oracle/apps/xxkrl/ba/webui/YeniKayitPG";

                pageContext.forwardImmediately(targetPage, null, (byte)0, null,params, true, "Y");

            }

           

            if("xAddCustomer".equals(event)){

               bakimAM.doRollback();

               /*oracle.jbo.domain.Number pOrderNumber;

               OAMessageTextInputBean pOrderNumberBean = (OAMessageTextInputBean)webBean.findChildRecursive("OrderNumber");

               pOrderNumber = new Number(Integer.parseInt(pOrderNumberBean.getValue(pageContext).toString()));

               HashMap params = new HashMap(2);

               params.put("pFromButton", "CREATECUSTOMER");

               params.put("pSiparisNumarasi",pOrderNumber);*/

               String targetPage = "OA.jsp?page=/xxkrl/oracle/apps/xxkrl/ba/webui/YeniMusteriPG";

              // pageContext.forwardImmediately(targetPage, null, (byte)0, null,params, true, "Y");

               pageContext.forwardImmediately(targetPage, null, (byte)0, null,null, true, "Y");

              

            }

            if("xUpdateCustomer".equals(event)){

               bakimAM.doRollback();

               String targetPage = "OA.jsp?page=/xxkrl/oracle/apps/xxkrl/ba/webui/MusteriAramaPG";

               pageContext.forwardImmediately(targetPage, null, (byte)0, null,null, true, "Y");        

            }

           

             if("xDownload".equals(event)){

                 try{              

                     writeXLSXFile(pageContext, "SearchResultsVO1");

                 }catch(IOException e){

                       e.printStackTrace();      

                 }                       

             }   

        }

       

          public  void writeXLSXFile(OAPageContext pageContext,String view_inst_name) throws IOException {

            

            OAViewObject vo = (OAViewObject) pageContext.getRootApplicationModule().findViewObject(view_inst_name);          

            String sheetName = "Bakim Anlasmalari";//name of sheet

            HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();

         

            // Set excel property

       

            response.setHeader("Header-Name", "Codecombination");

            response.setHeader("Content-Length", "100000");

            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

            response.setHeader("Content-Disposition","attachment; filename=" + "Bakim Anlasmalari" + ".xlsx");

            response.setHeader("Cache-Control","max-age=0");

       

       

            XSSFWorkbook wb = new XSSFWorkbook();

            XSSFSheet sheet = wb.createSheet(sheetName);

           

            CellStyle style = wb.createCellStyle();

            Font font = wb.createFont();

            font.setBoldweight(Font.BOLDWEIGHT_BOLD);

            style.setFont(font);

           

            // Create header

           

            XSSFRow row12 = sheet.createRow(0);

       

            XSSFCell celh0 = row12.createCell(0);

            celh0.setCellValue("BA NUMARASI");

            celh0.setCellStyle(style);

            XSSFCell celh1 = row12.createCell(1);

            celh1.setCellValue("BA BASLANGIC TARIHI");   

            celh1.setCellStyle(style);

            XSSFCell celh2 = row12.createCell(2);

            celh2.setCellValue("BA BITIS TARIHI");  

            celh2.setCellStyle(style);

            XSSFCell celh3 = row12.createCell(3);

            celh3.setCellValue("SIPARIS NUMARASI");

            celh3.setCellStyle(style);

            XSSFCell celh4 = row12.createCell(4);

            celh4.setCellValue("FATURA NUMARASI");

            celh4.setCellStyle(style);

            XSSFCell celh5 = row12.createCell(5);

            celh5.setCellValue("SATIS KANALI");

            celh5.setCellStyle(style);

            XSSFCell celh6 = row12.createCell(6);

            celh6.setCellValue("YS ADI");

            celh6.setCellStyle(style);

            XSSFCell celh7 = row12.createCell(7);

            celh7.setCellValue("YS KODU");

            celh7.setCellStyle(style);

            XSSFCell celh8 = row12.createCell(8);

            celh8.setCellValue("YS SORUMLUSU");

            celh8.setCellStyle(style);

            XSSFCell celh9 = row12.createCell(9);

            celh9.setCellValue("SD SORUMLUSU");

            celh9.setCellStyle(style);

            XSSFCell celh10 = row12.createCell(10);

            celh10.setCellValue("KAYIT TARIHI");

            celh10.setCellStyle(style);

            XSSFCell celh11 = row12.createCell(11);

            celh11.setCellValue("MUSTERI");

            celh11.setCellStyle(style);

            XSSFCell celh12 = row12.createCell(12);

            celh12.setCellValue("MH SORUMLUSU");

            celh12.setCellStyle(style);

            XSSFCell celh13 = row12.createCell(13);

            celh13.setCellValue("SANTRAL MODELI");

            celh13.setCellStyle(style);

            XSSFCell celh14 = row12.createCell(14);

            celh14.setCellValue("SANTRAL KAPASITE");

            celh14.setCellStyle(style);

            XSSFCell celh15 = row12.createCell(15);

            celh15.setCellValue("UCRET TIPI");

            celh15.setCellStyle(style);

            XSSFCell celh16 = row12.createCell(16);

            celh16.setCellValue("BAKIM SOZLESME FATURA NO");

            celh16.setCellStyle(style);

       

            int f=1;

            for(SearchResultsVORowImpl row = (SearchResultsVORowImpl) vo.first(); row != null;row = (SearchResultsVORowImpl) vo.next())

            {    

            // Create line

                XSSFRow row1 = sheet.createRow(f);

            

                         for (int i = 0; i < vo.getAttributeCount(); i++)

                         {

                       

                              if (i==0) {

                                   XSSFCell cell = row1.createCell(i);                                                       

                                   cell.setCellValue(row.getBaNumber());              

                              }

                             

                              if (i==1) {

                             

                                  String dob;

                                  dob = row.getStartDate().toString();

                                  String OLD_FORMAT = "yyyy-MM-dd";

                                  String NEW_FORMAT = "dd.MM.yyyy";

                                  String NewDate ;

                                  NewDate = "";

                                  if (dob != null) {

                                    try {

                                      SimpleDateFormat OldDateFormat = new SimpleDateFormat(OLD_FORMAT);

                                      Date dt = OldDateFormat.parse(dob);

                                      OldDateFormat.applyPattern(NEW_FORMAT);

                                      NewDate = OldDateFormat.format(dt);

                                    } catch (ParseException e) {

                                      e.printStackTrace();

                                    }

                                  }

                                                     

                                      XSSFCell cell = row1.createCell(i);      

                                      cell.setCellValue(NewDate); 

                              }         

                             

                              if (i==2) {

                                                    

                                 String dob;

                                 dob = row.getEndDate().toString();

                                 String OLD_FORMAT = "yyyy-MM-dd";

                                 String NEW_FORMAT = "dd.MM.yyyy";

                                 String NewDate ;

                                 NewDate = "";

                                 if (dob != null) {

                                   try {

                                     SimpleDateFormat OldDateFormat = new SimpleDateFormat(OLD_FORMAT);

                                     Date dt = OldDateFormat.parse(dob);

                                     OldDateFormat.applyPattern(NEW_FORMAT);

                                     NewDate = OldDateFormat.format(dt);

                                   } catch (ParseException e) {

                                     e.printStackTrace();

                                   }

                                 }                       

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(NewDate);                                  

                             }

                            

                             if (i==3) {                                          

                                  if(row.getOrderNumber() != null){

                                     XSSFCell cell = row1.createCell(i);      

                                     String orderNumberStr = row.getOrderNumber().toString();

                                     cell.setCellValue(orderNumberStr); 

                                  }

                             }

                            

                             if (i==4) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getTrxNumber());     

                             }   

                            

                             if (i==5) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getSatisKanaliTanim());  

                             }    

                            

                             if (i==6) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getYsName());

                             }       

                            

                             if (i==7) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getYsCode());

                             }

                            

                             if (i==8) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getYsExecutive());

                             }  

                            

                             if (i==9) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getSdName());                                             

                             }  

                            

                             if (i==10) {

                                                 

                                 String dob;

                                 dob = row.getTransactionDate().toString();

                                 String OLD_FORMAT = "yyyy-MM-dd HH:mm:ss";

                                 String NEW_FORMAT = "dd.MM.yyyy";

                                 String NewDate ;

                                 NewDate = "";

                                 if (dob != null) {

                                   try {

                                     SimpleDateFormat OldDateFormat = new SimpleDateFormat(OLD_FORMAT);

                                     Date dt = OldDateFormat.parse(dob);

                                     OldDateFormat.applyPattern(NEW_FORMAT);

                                     NewDate = OldDateFormat.format(dt);

                                   } catch (ParseException e) {

                                     e.printStackTrace();                              

                                   }

                                 }

                                

                                 XSSFCell cell = row1.createCell(i);      

                                 cell.setCellValue(NewDate);                 

       

                             }  

                            

                             if (i==11) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getCustomerName()); 

                             } 

                            

                             if (i==12) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getMhSorumlusu());   

                             }  

                            

                             if (i==13) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getSantralModeli());   

                             } 

                            

                             if (i==14) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getKapasite());   

                             }  

                            

                             if (i==15) {

                                     XSSFCell cell = row1.createCell(i);      

                                     cell.setCellValue(row.getUcrtp());

                             }  

                            

                             if (i==16) {   

                                    if(row.getBakimSozlesmeFaturaNo() != null){   

                                      XSSFCell cell = row1.createCell(i);      

                                      cell.setCellValue(row.getBakimSozlesmeFaturaNo().toString());

                                    }

                             }

                         }

                f=f+1;

            }

            ByteArrayOutputStream outByteStream = new ByteArrayOutputStream();

            wb.write(outByteStream);

            byte[] outArray = outByteStream.toByteArray();

            response.setContentLength(outArray.length);

            ServletOutputStream outStream = response.getOutputStream();

            outStream.write(outArray);

            outStream.flush();

            outStream.close(); 

          }

      }