0

I've looked at some wicket tutorials, gone through similar questions but couldn't get my answer. Can you give me a simple example of how to put a link on a page, and the user can download a file when the link is clicked?

I'll retrieve the file from a database table (blob column). The thing is, I'll need to put the link out there on the page (with the file name on it) without going to the database yet. When it's clicked then I'll retrieve the file and the user can download it.

Thanks in advance.

newwebdev
  • 407
  • 2
  • 7
  • 13
  • I really dont undestant how would you retrieve the file name without quering the database...? – mvlupan Mar 15 '13 at 12:43
  • What I meant was, assume that I have the filename already. I just don't want to retrieve the contents of the file yet since it's big. – newwebdev Mar 15 '13 at 13:12
  • Use the example page i have posted [below](http://stackoverflow.com/a/15433037/1165292)...There the object that is send to the "client" is generated when needed..That is was you need using AbstractReadOnlyModel and overriding the getObject() method – mvlupan Mar 15 '13 at 13:40
  • have you looked into [ResourceLink](http://wicket.apache.org/apidocs/1.5/org/apache/wicket/markup/html/link/ResourceLink.html)? It's used to generate a resource once the linked is clicked. – Raystorm Mar 17 '13 at 08:37

1 Answers1

0

I think that the best solution is to extends Wicket DownloadLink.There are multiple questions on StackOverflow regarding this issue ...example But i really dont think it is posible to create the download link without querying the database for the file name. Of course you will only encounter this problem if you need the file name in the link...or something like that..You could always create a link with a static name ex : "Download file" without the file name and the you would not need to query the database.

Community
  • 1
  • 1
mvlupan
  • 3,536
  • 3
  • 22
  • 35