Reputation: 1583
I have to re-do a page which contains links to pdf files.
So far the page looks something like this:
NewsPanel.html
<wicket:fragment wicket:id="news">
[...]
<ul>
<li><a href="res/pdf/NewsAugust.pdf" target="_blank">August</a></li>
<li><a href="res/pdf/NewsSeptember.pdf" target="_blank">September</a></li>
</ul>
[...]
</wicket:fragment>
And now I have to build the links with information from the Data Base.
I have tried something like this:
NewsPanel.java
[...]
Resource pdfResource = new WebResource() {
private static final long serialVersionUID = 1L;
@Override
public IResourceStream getResourceStream() {
File pdf = new File("res/newsletter/September.pdf");
IResourceStream stream = new FileResourceStream(pdf);
return stream;
}
};
ResourceLink<Void> resourceLink = new ResourceLink<Void>("pdf", pdfResource);
add(resourceLink);
resourceLink.add(new Label("label", new Model<String>("September")));
[...]
NewsPanel.html
<wicket:fragment wicket:id="news">
[...]
<ul>
<li><a href="#" wicket:id="pdf"><wicket:container wicket:id="label"></wicket:container></a></li>
</ul>
</wicket:fragment>
But when I click the link, it shows a 404 error...
What's the correct way to do this?
Upvotes: 1
Views: 1052
Reputation: 1583
And as always, as soon as I post a question here, I realize the answer, it was as simple as this: NewsPanel.java
ExternalLink link = new ExternalLink("pdf", "res/newsletter/September.pdf", "September");
add(link);
NewsPanel.html
<a href="#" wicket:id="pdf">
Upvotes: 3