Announcement

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

    DMI RPC downloadResult not working?

    I am trying to invoke a Java program on a remote server and download the resulting PDF report. I finally got it all to work. Sort of. When I click the button the program runs with no sign of error. And, then the browser window goes blank, except for a single form text field. When I expand it I see the following contents.
    Code:
    //isc_RPCResponseStart-->[{status:0,data:"http://planetproject.jelastic.servint.net/temp/MeetingAgenda10.pdf"}]//isc_RPCResponseEnd
    If I copy just the URL and paste it into an address field, then the PDF file opens up without problem and displays the report. The DMI call includes downloadResult: true and downloadToNewWindow:false. So, my expectation was that the URL returned would cause a SAVE dialog to open up for the user to download the PDF file. This is the code on the button.click.
    Code:
    	DMI.call({
    		appID: "PlanetProject", 
    		className: "com.planetproject.server.reports.MeetingAgenda10", 
    		methodName: "report",
    		arguments: [String(form.getValue("MeetingDate")),
    					String(form.getValue("MeetingTime")),
    					String(Application.currentMeetingTypeID),
    					String(form.getValue("AgendaPrintOptions"))
    				   ],
    		requestParams: { downloadResult: true, downloadToNewWindow:false } 
    	});
    I did not see any examples in the forum of this particular call. So, I don't know if my usage is a good idea or just plain silly.

    If I am close, it would be nice to know it. Anyway, I am making my Java program into a servlet. I needed to do that anyway. I was just hoping to get the result I need in stages.

    Thanks,

    Rick

    P.S. I am running SmartClient Version: v8.2p_2012-07-19/EVAL Development Only on Mozilla Firefox 12.0 with Firebug using Windows XP Pro 32 bit.
    Attached Files
    Last edited by RickBollinger; 17 Aug 2012, 11:33.

    #2
    This looks like an issue with your server logic.

    Having set downloadResult:true client-side, your server logic should call rpcManager.doCustomResponse() and stream the binary data of the PDF to the servletResponse's outputStream.

    It looks like instead, you're just returning a URL and hoping for magic :)

    Comment


      #3
      You caught me believing in magic red-handed ;)

      The program that returned the URL was not a servlet. Just a java program with an entry point that could return a URL string pointing to a real PDF file.

      In preparation also was a real servlet. So, converting to that, now I have something to test. It does reponse.getOutputStream() to make the place to write the PDF. I am hoping for more magic: giving the returning attachment a server based filename with the expectation that a URL or location is returned eventually.

      I will be happy at this point to see my servlet run. Next iteration I can try call rpcManager.doCustomResponse(). But, I will have to do some more research. I think the only server-side logic methods I have are from the HTTP request and response objects.

      Not to worry. I will do my homework to prepare for the next attempt.

      Thanks,

      Rick

      Comment


        #4
        I not only believe in magic, now. But, Santa Clause and the Easter Bunny. Check out the attached image.

        My servlet ran without a hitch. (Well, maybe one hitch for a bad column name.) It populated an outputStream with a PDF file which came back to the browser.

        Between the client the server and the framework, a filename was manufactured for a successful download.

        All I did on the client was click a button.
        Code:
        	var form = MeetingForm;
        	
        	RPCManager.sendRequest({
        		httpMethod: "POST",
        		actionURL: "/servlet/MeetingAgendaServlet11",
        		params: {	meetingDate:		String(form.getValue("MeetingDate")),
        					meetingTime:		String(form.getValue("MeetingTime")),
        					meetingTypeID:		String(Application.currentMeetingTypeID),
        					agendaPrintOptions: String(form.getValue("AgendaPrintOptions"))
        		},
        		downloadResult: true, 
        		downloadToNewWindow:false,
        		useSimpleHttp: true,
        		
        	});
        Even the form values got down into the report. Boy, that downloadResult worked really well!

        I guess I won't need that next attempt. I just need to clean up the servlet so it has init() and destroy() so it can stay resident in memory and only open and close the database connection once for each time it is loaded.

        I might need rpcManager.doCustomResponse() at some point in the future.

        Thanks again for all the help.

        Rick
        Attached Files

        Comment

        Working...
        X