I usually wrap a custom AbstractResource instance in a ResourceReference,
and put that into the ResourceLink. AbstractResource#newResourceResponse()
is called when the link is clicked. You can query for the bytes there, and
write them to the response in your ResourceResponse's WriteCallback. For a
download, the relevant setters are:

ResourceResponse response = new ResourceResponse();
response.setFileName(...);
response.setContentType(...);
response.setContentLength(...);
response.setContentDisposition(ContentDisposition.ATTACHMENT);
response.setWriteCallback(new WriteCallback() {...});

On Sun, Oct 14, 2012 at 7:45 PM, Michael Jaruska
<michael.jaru...@gmail.com>wrote:

> Dan, thank you for links and points.
>
> The true is that I have data in database so I would like streaming them.
> Is the right
> way put them in temp file first and then send it into browser with
> DownloadLink?
>
> After some googling I noticed that ResourceLink should be like
> DownloadLink but for me
> better - it's for streamed data. But can't find any example for wicket 1.5
> :-(
>
> MJ
>
>
>
> On 14.10.2012 21:00, Dan Retzlaff wrote:
>
>> Michael, check out the DownloadLink example here:
>> http://www.wicket-library.com/**wicket-examples/linkomatic/**home<http://www.wicket-library.com/wicket-examples/linkomatic/home>
>>
>> Also check out the code for DownloadLink itself, and you'll see
>> 1. Your IModel must return a File, but yours returns bytes.
>> 2. The download is initiated in DownloadLink#onClick, which you have
>> blocked with your subclass.
>>
>> Hope that helps,
>> Dan
>>
>> On Sun, Oct 14, 2012 at 5:09 PM, Michael Jaruska
>> <michael.jaru...@gmail.com>**wrote:
>>
>>  Hi,
>>>
>>> what to add into onClick() in DownloadLink if I need return to client
>>> generated .pdf
>>> stream as a .pdf file?
>>>
>>> My code:
>>>
>>> IModel pdfStreamModel = new AbstractReadOnlyModel()
>>> {
>>>          public Object getObject()
>>>          {
>>>                  return getPdfStreamBytes();
>>>          }
>>> };
>>> DownloadLink downloadLink = new DownloadLink("downloadLink",
>>> pdfStreamModel, getPdfDocumentName())
>>> {
>>>          public void onClick()
>>>          {
>>>                  System.out.println("clicking works");
>>>          }
>>> };
>>>
>>> Model works, DownloadLink is added into my markup. But I can't find any
>>> example how to deal
>>> code into onClick() in DownloadLink in a way it will return my generated
>>> .pdf stream in model.
>>>
>>> Thank folks,
>>>
>>> MJ
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: 
>>> users-unsubscribe@wicket.**apa**che.org<http://apache.org>
>>> <users-unsubscribe@**wicket.apache.org<users-unsubscr...@wicket.apache.org>
>>> >
>>>
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>>>
>>>
>>>
>>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org<users-unsubscr...@wicket.apache.org>
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to