Search in sources :

Example 6 with AjaxDownloadBehaviorFromStream

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AjaxDownloadBehaviorFromStream(com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour)

Aggregations

AjaxDownloadBehaviorFromStream (com.evolveum.midpoint.web.component.AjaxDownloadBehaviorFromStream)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)6 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)3 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 Form (org.apache.wicket.markup.html.form.Form)3 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)2 InputStream (java.io.InputStream)2 AjaxFormSubmitBehavior (org.apache.wicket.ajax.form.AjaxFormSubmitBehavior)2 FileUploadField (org.apache.wicket.markup.html.form.upload.FileUploadField)2 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)1 Task (com.evolveum.midpoint.task.api.Task)1 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)1 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)1 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)1 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)1 ReportOutputType (com.evolveum.midpoint.xml.ns._public.common.common_3.ReportOutputType)1 IOException (java.io.IOException)1