-
1. http get request by jsfunction
erbora00 Feb 18, 2011 6:59 AM (in response to erbora00)OK, I just found out that we can specify a URL in the action parameter of jsfunction.
<a:jsFunction name="test" ajaxSingle="true"
action="/seam/resource/myresource" oncomplete="onTestEnd();">
</a:jsFunction>
Here I had to modify the getResourcePath method so that it returns the suffix as well.
public String getResourcePath() {
return "/myresource.seam";
}
Now again same thing as DocumentStore; the data is downloaded as a file in the browser (Chrome).
Can't this be done in the background?
And the oncomplete callback never gets called with this method...
I am writing the data using the HttpServletResponse object in the getResource method of AbstractResource.
Below is the getResource method I use for testing:
public void getResource(HttpServletRequest httpservletrequest,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/octet-stream");
response.setStatus(200);
response.flushBuffer();
ServletOutputStream out = response.getOutputStream();
byte[] data = new byte[4096];
for (int i = 0; i < 4096; i++)
data[i] = (byte) i;
out.write(data);
response.flushBuffer();
out.close();
}
-
2. http get request by jsfunction
nbelaevski Feb 18, 2011 7:07 AM (in response to erbora00)Hi,
Why not simply use jQuery.get(...) for this?
-
3. http get request by jsfunction
erbora00 Feb 18, 2011 7:13 AM (in response to nbelaevski)Because I haven't used jQuery before.
I will now learn and try it and then let you know the results.
Thanks for the pointer.
-
4. http get request by jsfunction
erbora00 Feb 18, 2011 7:58 AM (in response to erbora00)Hi Nick
That works perfectly..
Thanks very much..