Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Can't you use the constructor that takes a <code>Model</code> as argument? And make the <code>Model</code> generate the <code>File</code> in its <code>getObject()</code>. A <code>LoadableDetachableModel</code> is a good choice, given that <code>load()</code>, and therefore file generation, will be invoked only once.</p> <p>If the file is to be freshly generated every time the link is clicked, use <a href="http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/link/DownloadLink.html#setDeleteAfterDownload(boolean)" rel="noreferrer"><code>DownloadLink.setDeleteAfterDownload(true)</code></a> to ensure the File is automatically deleted once it is served.</p> <p>I don't use 1.4, but the source code in 1.3 shows that the <code>File</code> is retrieved by means of <code>getModelObject()</code> in the <code>onClick()</code> method of the <code>Link</code>.</p> <pre><code>IModel fileModel = new AbstractReadOnlyModel(){ public Object getObject() { return generateFile(); } }; DownloadLink link = new DownloadLink(linkId, fileModel, "report.pdf"); </code></pre> <p>Source code of <a href="http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/link/DownloadLink.html#onClick()" rel="noreferrer"><code>DownloadLink.onClick()</code></a></p> <pre><code>public void onClick() { final File file = (File)getModelObject(); ... IResourceStream resourceStream = new FileResourceStream( new org.apache.wicket.util.file.File(file)); getRequestCycle().setRequestTarget(.../* uses resourceStream */...); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload