use of com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream in project midpoint by Evolveum.
the class TaskOperationalButtonsPanel method createDownloadReportButton.
private void createDownloadReportButton(RepeatingView repeatingView) {
final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior = new AjaxDownloadBehaviorFromStream() {
private static final long serialVersionUID = 1L;
@Override
protected InputStream initStream() {
ReportDataType reportObject = getReportData();
if (reportObject != null) {
return PageCreatedReports.createReport(reportObject, this, getPageBase());
} else {
return null;
}
}
@Override
public String getFileName() {
ReportDataType reportObject = getReportData();
return PageCreatedReports.getReportFileName(reportObject);
}
};
add(ajaxDownloadBehavior);
AjaxButton download = new AjaxButton(repeatingView.newChildId(), createStringResource("PageTask.download.report")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ajaxDownloadBehavior.initiate(target);
}
};
download.add(new VisibleBehaviour(this::isDownloadReportVisible));
download.add(AttributeAppender.append("class", "btn-primary"));
repeatingView.add(download);
}
Aggregations