示例#1
0
  private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);

    final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior =
        new AjaxDownloadBehaviorFromStream() {
          @Override
          protected InputStream initStream() {
            return createReport(this);
          }

          @Override
          public String getFileName() {
            return getReportFileName();
          }
        };

    mainForm.add(ajaxDownloadBehavior);

    ObjectDataProvider provider =
        new ObjectDataProvider(PageCreatedReports.this, ReportOutputType.class) {

          @Override
          protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
            ReportsStorage storage = getSessionStorage().getReports();
            storage.setReportOutputsPaging(paging);
          }

          @Override
          public ObjectQuery getQuery() {
            return createQuery();
          }
        };

    BoxedTablePanel table =
        new BoxedTablePanel(
            ID_CREATED_REPORTS_TABLE,
            provider,
            initColumns(ajaxDownloadBehavior),
            UserProfileStorage.TableId.PAGE_CREATED_REPORTS_PANEL,
            (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_CREATED_REPORTS_PANEL)) {

          @Override
          protected WebMarkupContainer createHeader(String headerId) {
            return new SearchFragment(
                headerId, ID_TABLE_HEADER, PageCreatedReports.this, searchModel);
          }
        };
    table.setShowPaging(true);
    table.setOutputMarkupId(true);
    mainForm.add(table);
  }
示例#2
0
  private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);

    final AjaxDownloadBehaviorFromStream ajaxDownloadBehavior =
        new AjaxDownloadBehaviorFromStream() {

          @Override
          protected InputStream initStream() {
            if (currentReport != null) {
              String contentType = reportExportTypeMap.get(currentReport.getExportType());
              if (StringUtils.isEmpty(contentType)) {
                contentType = "multipart/mixed; charset=UTF-8";
              }
              setContentType(contentType);
            }

            return createReport();
          }
        };

    mainForm.add(ajaxDownloadBehavior);

    ObjectDataProvider provider =
        new ObjectDataProvider(PageCreatedReports.this, ReportOutputType.class) {

          @Override
          protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
            ReportsStorage storage = getSessionStorage().getReports();
            storage.setReportOutputsPaging(paging);
          }

          @Override
          public ObjectQuery getQuery() {
            return createQuery();
          }
        };

    BoxedTablePanel table =
        new BoxedTablePanel(
            ID_CREATED_REPORTS_TABLE,
            provider,
            initColumns(ajaxDownloadBehavior),
            UserProfileStorage.TableId.PAGE_CREATED_REPORTS_PANEL,
            (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_CREATED_REPORTS_PANEL)) {

          @Override
          protected WebMarkupContainer createHeader(String headerId) {
            return new SearchFragment(
                headerId, ID_TABLE_HEADER, PageCreatedReports.this, searchModel);
          }
        };
    table.setShowPaging(true);
    table.setOutputMarkupId(true);
    mainForm.add(table);

    add(
        new ConfirmationDialog(
            ID_CONFIRM_DELETE,
            createStringResource("pageCreatedReports.dialog.title.confirmDelete"),
            createDeleteConfirmString()) {

          @Override
          public void yesPerformed(AjaxRequestTarget target) {
            close(target);

            ReportDeleteDialogDto dto = deleteModel.getObject();
            switch (dto.getOperation()) {
              case DELETE_SINGLE:
                deleteSelectedConfirmedPerformed(target, Arrays.asList(dto.getObjects().get(0)));
                break;
              case DELETE_SELECTED:
                deleteSelectedConfirmedPerformed(target, dto.getObjects());
                break;
              case DELETE_ALL:
                deleteAllConfirmedPerformed(target);
                break;
            }
          }
        });
  }