Hi,
I have a scenario where i have to download a file which gets generated when the user send the request to download. so everytime user ask for download i have to pass certain parameters as well along with the request.
I have created a DMI having a downloadFile method, a DS having a field of type binary, an object having a getter setter method of property of type Inputstream defined in DS. so what i did was onclick of a button i call a js function below, passed some parameters and call the DMI.downloadFile function:
function openHelpContent(){
var data = {};
data.param1 = "123";
data.param2 = "param2";
isc.DataSource.get("downloadDS").downloadFile({data: data});
}
DMI class below:
public class DownloadDMI {
public DSResponse downloadFile(DSRequest dsRequest) throws Exception {
long t1 = System.currentTimeMillis();
DSResponse dsResponse = new DSResponse();
DownloadItem file= new DownloadItem();
InputStream stream = new FileInputStream( "C:/Eval_Users_Guide.pdf" );
file.setFile(stream);
dsResponse.setData(file);
return dsResponse;
}
}
DS code below:
<DataSource ID="downloadDS" serverType="generic">
<fields>
<field name="file" type="binary"/>
</fields>
<serverObject lookupStyle="new" className="com.ftid.evs.corp.webapp.smartclient.dmi.DownloadDMI" />
</DataSource>
Object code below:
public class DownloadItem {
private InputStream file;
public InputStream getFile() {
return file;
}
public void setFile(InputStream file) {
this.file = file;
}
}
But i am getting the exception:
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
at com.isomorphic.rpc.RPCManager.completeResponse(RPCManager.java:662)
at com.isomorphic.rpc.RPCManager.send(RPCManager.java:499)
at com.isomorphic.rpc.RPCManager.sendFailure(RPCManager.java:582)
at com.isomorphic.rpc.RPCManager.sendFailure(RPCManager.java:603)
at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:112)
at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:248)
Please let me know what wrong i am doing?
I have a scenario where i have to download a file which gets generated when the user send the request to download. so everytime user ask for download i have to pass certain parameters as well along with the request.
I have created a DMI having a downloadFile method, a DS having a field of type binary, an object having a getter setter method of property of type Inputstream defined in DS. so what i did was onclick of a button i call a js function below, passed some parameters and call the DMI.downloadFile function:
function openHelpContent(){
var data = {};
data.param1 = "123";
data.param2 = "param2";
isc.DataSource.get("downloadDS").downloadFile({data: data});
}
DMI class below:
public class DownloadDMI {
public DSResponse downloadFile(DSRequest dsRequest) throws Exception {
long t1 = System.currentTimeMillis();
DSResponse dsResponse = new DSResponse();
DownloadItem file= new DownloadItem();
InputStream stream = new FileInputStream( "C:/Eval_Users_Guide.pdf" );
file.setFile(stream);
dsResponse.setData(file);
return dsResponse;
}
}
DS code below:
<DataSource ID="downloadDS" serverType="generic">
<fields>
<field name="file" type="binary"/>
</fields>
<serverObject lookupStyle="new" className="com.ftid.evs.corp.webapp.smartclient.dmi.DownloadDMI" />
</DataSource>
Object code below:
public class DownloadItem {
private InputStream file;
public InputStream getFile() {
return file;
}
public void setFile(InputStream file) {
this.file = file;
}
}
But i am getting the exception:
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
at com.isomorphic.rpc.RPCManager.completeResponse(RPCManager.java:662)
at com.isomorphic.rpc.RPCManager.send(RPCManager.java:499)
at com.isomorphic.rpc.RPCManager.sendFailure(RPCManager.java:582)
at com.isomorphic.rpc.RPCManager.sendFailure(RPCManager.java:603)
at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:112)
at com.isomorphic.servlet.IDACall.doPost(IDACall.java:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:248)
Please let me know what wrong i am doing?
Comment