1

In my Web methods application in Java I'm selecting a file and downloading it.When the download window closes I made the control to be directed back to parent page. I implemented it by creating an IPortletURL calling BasePortletPageBean.createRenderURL(),setted its base URL to a portlet's alias name where I want to redirect. Then called FacesContext redirect method. It worked fine in Web methods 8.0 and I had developed it in a Windows XP machine. Now I imported the same project to a web methods 8.2 installed Windows 7 machine, but now its not working. Kindly help me.

 public String downloadMaster() {


    List<Object> selectedRows = getFnamesProvider2().getSelectedRows();

    if (getFnamesProvider2().getSelectedRows() != null
            && getFnamesProvider2().getSelectedRows().size() != 0) {

        for (Iterator iterator = selectedRows.iterator(); iterator
                .hasNext();) {

            com.webmethods.caf.FileNames details = (com.webmethods.caf.FileNames) iterator
                    .next();


            System.out.println("Iterator Output!!!!!!!!!!!!!!!!!!!!!!!"
                    + details.toString());
            FileInputStream fileInputStream = null;
            OutputStream out = null;
            try {

                String filename = "C:/SoftwareAG/MWS/Projects/"
                        + getProjName() + "/"
                        + session.getAttribute("folder").toString()
                        + "/search/" + details.getFileName();

                if (response == null) {
                    response = PortalServlet.getCurrentResponse();
                    setResponse(response);
                }
                if (response.getContentType() == null
                        || (!(response.getContentType()
                                .equalsIgnoreCase("APPLICATION/DOWNLOAD")))) {
                    if (response == null) {
                        response = PortalServlet.getCurrentResponse();
                    }
                    getResponse().setContentType("APPLICATION/DOWNLOAD");
                }
                response.setHeader("Content-Disposition", "attachment"
                        + "filename=" + details.getFileName());

                File fileToDownload = new File(filename);

                fileInputStream = new FileInputStream(fileToDownload);
                response.setContentLength(fileInputStream.available());
                out = response.getOutputStream();
                response.setHeader("Content-Disposition",
                        "attachment;filename=" + details.getFileName());

                int i;
                while ((i = fileInputStream.read()) != -1) {
                    out.write(i);
                }
                fileInputStream.close();
                out.close();

                List<Object> selRows = getFnamesProvider2()
                        .getSelectedRows();



            } catch (Exception e) // file IO errors
            {
                e.printStackTrace();
            } finally {

                try {

                    IPortletURL renderURL = createRenderUrl();

                    renderURL.setBaseURL("/kneipp.NewProject");
                    System.out.println("::::::renderURL::::::" + renderURL);

                    getFacesContext().getExternalContext().redirect(
                            renderURL.toString());



                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }



            }


        }
    }

    return OUTCOME_OK;

}
AndroidLearner
  • 4,500
  • 4
  • 31
  • 62
Cheese
  • 245
  • 2
  • 3
  • 9

1 Answers1

0

Make sure you are always using the full paths, Webmethods 8.2 needs the full path for urls or any ressources like images also. This might be a cause of your problem.

Nick
  • 605
  • 3
  • 11
  • 27
  • I tried that too but of no use! Due to some immediate requirement I had to move back to WM 8.0 – Cheese Mar 05 '13 at 11:58