I have button which works:
Button options = new Button("sheets", new StringResourceModel("sheets", null)) {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit() {
setResponsePage(new TournamentOptionsPage(tournament, table) {
private static final long serialVersionUID = 1L;
});
}
};
now I want to replace this button with downloadLink:
add(new DownloadLink("sheets", new AbstractReadOnlyModel<File>() {
private static final long serialVersionUID = 1L;
@Override
public File getObject() {
File tempFile;
try {
tempFile = PdfFactory.createSheets(WicketApplication.getSheetsPath(),
tournamentService.getSchedule(table, tournament), table);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return tempFile;
}
}, new StringResourceModel("sheets", null)).setCacheDuration(Duration.NONE).setDeleteAfterDownload(true));
but here I have problem with StringResourceModel and when I push link I got exception:
Caused by: java.util.MissingResourceException: Unable to find property: 'sheets'
at org.apache.wicket.Localizer.getString(Localizer.java:239)
at org.apache.wicket.Localizer.getString(Localizer.java:170)
at org.apache.wicket.model.StringResourceModel.getString(StringResourceModel.java:425)
at org.apache.wicket.model.StringResourceModel.getString(StringResourceModel.java:400)
at org.apache.wicket.model.StringResourceModel.load(StringResourceModel.java:583)
at org.apache.wicket.model.StringResourceModel.load(StringResourceModel.java:182)
at org.apache.wicket.model.LoadableDetachableModel.getObject(LoadableDetachableModel.java:119)
at org.apache.wicket.markup.html.link.DownloadLink.onClick(DownloadLink.java:151)
at org.apache.wicket.markup.html.link.Link.onLinkClicked(Link.java:188)
Why this doesnt work ?
I’ve opened an issue to discuss this problem
https://issues.apache.org/jira/browse/WICKET-4738