Display Excel Report

Hello Isomorphic,

I have to export the current grid contents into an excel format, so I pass the grid content back to server which then creates an excel file successfully but I am not able to open a save dialog on the user side. I am getting error as
“The data necessary to complete this operation is not yet available.”
Following is my code to send RPC request.
Why am I getting this error ?

isc.Button.create({ width:"80",name:"submit", title:"Create",  ID:"createBtn",   autoDraw:false,
    click:  function () {
      		
    RPCManager.send(stdSearchResult.getData(),alert("done"),  {    actionURL: "CreateReportAction.do" })     
	 }
});

Hi Sima,

To trigger file download, either just set window.location to the URL where the file will be downloaded (you can pass dat as URL params) or use the approach shown here of creating a form and calling submitForm().

Excel report is not opening

Hello Isomorphic,

With the following code new blank window is opening, but I am not getting that save dialog box on the user end. I am still getting that error.

" The data necessary to complete this operation is still not yet available."

RPCManager.send(stdSearchResult.getData(),window.open(“data”, “exportWindow”), { actionURL: “CreateReportAction.do” })

Hi Sima,

Again, don’t use the RPCManager, use window.location or submitForm(). Please re-read the previous post and the thread linked to.

SubmitForm()

Hello Isomorphic,
Thanks for the reply.
Now I am creating the form and submitting using submitForm().
I want to submit the listgrid data to the server to create excel report. I am using following code to submit which gives me null pointer exception at server side.
I am not able to pass this data to the server. Please guide me.
thanks

click:  function () {
      var excelForm = isc.DynamicForm.create({  
			autoDraw:true, 
			action: "CreateReportAction.do",
			method: "POST",
			//canSubmit: true,
			target: "someTarget",
	                        fields: [
			  { name: "list", type:"hidden", value: stdSearchResult.getData() }
            				 
				] 
        });
         
        excelForm.submitForm();
  
  }

Hi Sima,

Do you really need to send the dataset from the client to server, or can you just retrieve it on the server instead?

If you need to send it, you need to figure out a way to encode it. Are you using the SmartClient server? If so, the best approach might in fact be to use the RPCManager (which can encode any JavaScript and deliver it to Java) combined with forcing the transport to “hiddenFrame” to allow downloading.

RPCManager

Initialy I started with this approach.

RPCManager.send(stdSearchResult.getData(),window.open("", "exportWindow"), { actionURL: "CreateReportAction.do" })

I was able to send the data to the server and successfully able to create excel report, but not able to display it on the user end. So as per your suggestion now I am using submitForm() approach. to submit. Let me know if there is any other work around to display the report using RPCManager.

Sima

As we just mentioned - you could send the data to the server via the RPCManager and use the rpcRequest.transport:“hiddenFrame” setting to avoid using transport:“xmlHttpRequest”, which is the default, and cannot download files.

Thanks

Yes,
It is working now after setting transport:“hiddenFrame”.
Thank You!!!
Sima

One more question

This is my code to send rpcRequest to server.

 isc.RPCManager.sendRequest({
   actionURL: "CreateReportAction.do",
    transport: "hiddenFrame",
    data: stdSearchResult.getData(),
    callback: window.open("", "exportWindow")
    
   });

It is opening the report just fine.
Now my question is how to send more data(for ex: I want to send search parameters and arraylist) to the server. Do I need to create a datasource? Please give me some feedback.

Sima

You can pass any JavaScript structure to the SmartClient Server and it will be translated to Java according to the rules in the docs for rpcRequest.data. So for example:

isc.RPCManager.sendRequest({
    actionURL: "CreateReportAction.do",
    transport: "hiddenFrame",
    data: {
         myArray : stdSearchResult.getData(),
         myCriteria : [i]someForm.getValuesAsCriteria()[/i]
    },
    callback: window.open("", "exportWindow")    
});

get Data on server side

Hello,
Isomorphic, Thanks for the response. How do I retrive these values on the server side as key value pair.

rpc = new RPCManager(request, response);
 Object data = rpc.getData();
 System.out.println("client send:" + data.toString());

I am able to print this data as String, but I want to get as getCriteria key value pair.

Thanks
Sima

Hi Sima,

Please try to take a look at the docs before replying again -

So in the example we showed, expect getData() to be a Map - from there you simply use the Java Collections APIs (Map, List et al) to extract the data how you want it.