0 Replies Latest reply on Nov 12, 2012 11:03 AM by 971908

    XML Publisher Integration: OAF Page in invalid after PDF creation


      after days of googling and trying out various code changes in vain I hope to find help in this forum.

      The requirement is to extend the shipment page PosAsnMainPage in iSupplier Portal, adding the creation and download of PDF shipping documents for the orders selected in the table. These documents can be created for multiple shipments at once, always resulting in exactly one PDF file.

      To achieve this, I have added a button to the page that triggers the event "XxpoPrintShippingDocuments". In the controller class that extends the standard iSupplier Portal Controller, I have extended processFormRequest as follows:

      public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
      super.processFormRequest(pageContext, webBean);


      if(strEvent.equals("XxpoPrintShippingDocuments") && ("Y").equals(pageContext.getProfile("XXPO_DROPSHIPDOCUMENTS_SECURITY")))

      }//end processFormRequest

      private void outputDropshipDocuments()
      * on the view object, compose a list of PoHeaderId, PoLineId, LineLocationId from the rows that were selected
      OAViewObject vo = (OAViewObject) am.findViewObject("PosShipmentsVO");


      * Create PDF and a pop-up window for download
      //file info
      String fileName = pageContext.getMessage("XXPO", "XXPO_SD_FILENAME", null);
      String fileType = "PDF";
      boolean appendDate = true;

      //template info
      String appName = getApplicationName(vendorSiteId);
      String templKey = getTemplateKey(vendorSiteId);

      //user info
      Integer userId = new Integer(pageContext.getUserId());


      XxpoShippingDocumentsOut out = new XxpoShippingDocumentsOut(pageContext, webBean);

      * Save the printed status
      * This is supposed to be done here instead of during xml generation.
      * If any uncaught exception occurs before, the printed status remains unchanged.
      Class printClasses[] = {Map.class, Integer.class};
      Serializable printParams[] = {selectedOrders, userId};
      am.invokeMethod("savePrintStatus", printParams, printClasses);

      out.setFileInfo(fileName, fileType, appendDate);
      out.outputFile(xmlDoc, templKey, appName);

      } catch (Exception e)
      throw new OAException(e.getMessage(), OAException.WARNING);


      Finally, in XxpoShippingDocumentsOut.outputFile there is the following code:

      public void outputFile(XMLDocument xmlDoc, String templateKey, String appName)

      try {
      ServletOutputStream os = response.getOutputStream();

      response.setHeader("Content-Disposition", contentDisposition);

      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
      ByteArrayOutputStream File = new ByteArrayOutputStream();

      OADBTransactionImpl transaction = (OADBTransactionImpl) am.getOADBTransaction();

      * write the output to the HttpServletResponse object and flush -
      * this creates the pop-up window
      byte[] b = File.toByteArray();


      os.write(b, 0, b.length);

      } catch (Exception e) {
      throw new OAException(e.getMessage(), OAException.ERROR);


      Most of this works just fine - I select some orders on the standard iSP page, press the button and download the PDF file. But after that, the page is not "valid" any longer: the selections made are still visible but when a button is pressed (for instance the Create Shipment Notice or my own button), I get an error stating that items must be selected first.
      If I deactivate the lines in outputFile that set the response or flush the output stream, I can further use the previously made selections and everything works fine - except I don't get the PDF I need, obviously.

      Does anyone have an idea of what is missing here to reload the page or anything? Is there any workaround (i.e. opening the file downlad in a separate browser tab)?

      I'd be grateful for any advice on this. If you wish any further information, please let me know.

      Best regards,

      Edited by: 968905 on 01.11.2012 06:09

      Edited by: 968905 on 12.11.2012 03:02