Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    RPCCallback not getting executed for file download.

    Hi,
    My requirement is to show waiting indicator while generating and downloading the file. I am planning to show the waiting indicator before making a RPC call and then close the waiting indicator upon completion of RPC call. For that, i need to enter the rpc call back. But, my code is not entering the rpccallback if download result flag is true. Without it, download is not happening. Any idea, how to get this working.

    My code is as below. I m making simple http call to download the file.
    Client Side Code :


    RPCRequest req = new RPCRequest();
    req.setUseSimpleHttp(true);
    req.setDownloadResult(true); // without this file download not happening. But callback.execute() is executed. If we set this flag, call back is not executed.

    req.setHttpMethod("GET");
    req.setParams(criteria.getValues());

    req.setActionURL("/ysconfig/ela/reports/reportsGenerate");
    RPCManager.sendRequest(req, new RPCCallback() { // During profiling this takes around 530ms
    public void execute(RPCResponse response, Object rawData, RPCRequest request) {
    SC.say("called the call back..........."); // loadMaskWindowClear(dlg);
    }
    });

    Server side Controller Code:

    Added a new method :

    @RequestMapping(value = "/reports/reportsGenerate", method = RequestMethod.GET)
    public ModelAndView reportsGenerate(HttpServletRequest servletRequest, HttpServletResponse servletResponse) {
    logger.debug("entered reportsGenerate");
    // executedLeaseQuery.createRawDataReports(servletRequest, servletResponse);

    /*
    Above commented code will make call to service class and kick off report generation.
    */

    servletResponse.setStatus(servletResponse.SC_OK);
    servletResponse.setContentType("application/txt");
    servletResponse.setHeader("Content-Disposition", "attachment; filename=Test.txt");
    try {
    ServletOutputStream stream = servletResponse.getOutputStream();
    stream.write("abcadjflakjsdflka;sdlfjk;lasdjkfl;f asdfjl asd;fjla jsdfljk;sad fjasd ".getBytes());
    stream.flush();
    stream.close();
    } catch (Exception e) {
    e.printStackTrace();
    }

    logger.debug("done with reports Generation");
    return null;
    }

    Thanks in advance,
    Srihari Gouru.

    Client Version : v8.3p_2013-04-22/Pro Deployment (built 2013-04-22)
    Last edited by sriharirpipl; 25 Jul 2013, 02:51.
Working...
X