我有可以工作的按钮:
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;
});
}
};
现在我想用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));
但是在这里我遇到了 StringResourceModel 的问题,当我推送链接时出现异常:
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)
为什么这不起作用?