Package org.apache.openmeetings.web.util

Examples of org.apache.openmeetings.web.util.AjaxDownload


      // Set maximum size controlled by configuration
      setMaxSize(Bytes.bytes(ImportHelper.getMaxUploadSize(Application
          .getBean(ConfigurationDao.class))));

      // Add a component to download a file without page refresh
      final AjaxDownload download = new AjaxDownload();
      add(download);
      // add an download button
      add(new AjaxButton("download", this) {
        private static final long serialVersionUID = 839803820502260006L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

          File working_dir = OmFileHelper.getUploadBackupDir();

          String dateString = "backup_"
              + CalendarPatterns.getTimeForStreamId(new Date());

          File backup_dir = new File(working_dir, dateString);
          File backupFile = new File(backup_dir, dateString + ".zip");

          try {
            Application.getBean(BackupExport.class).performExport(
                backupFile,
                backup_dir,
                includeFilesInBackup.getConvertedInput()
                    .booleanValue());

            download.setFileName(backupFile.getName());
            download.setResourceStream(new FileResourceStream(
                backupFile));
            download.initiate(target);
          } catch (Exception e) {
            log.error("Exception on panel backup download ", e);
            uploadFeedback.error(e);
          }
View Full Code Here


        target.add(importFeedback);
      }
    });

    // Add a component to download a file without page refresh
    final AjaxDownload download = new AjaxDownload();
    langForm.add(download);

    langForm.add(new AjaxButton("export"){
      private static final long serialVersionUID = 1L;

      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

        final List<Fieldlanguagesvalues> flvList = getBean(FieldLanguagesValuesDao.class).getMixedFieldValuesList(language.getLanguage_id());

        FieldLanguage fl = getBean(FieldLanguageDao.class).getFieldLanguageById(language.getLanguage_id());
        if (fl != null && flvList != null) {
          download.setFileName(fl.getName() + ".xml");
          download.setResourceStream(new AbstractResourceStream() {
            private static final long serialVersionUID = 1L;
            private StringWriter sw;
            private InputStream is;
           
            public InputStream getInputStream() throws ResourceStreamNotFoundException {
              try {
                Document doc = createDocument(flvList, getBean(FieldLanguagesValuesDao.class).getUntranslatedFieldValuesList(language.getLanguage_id()));
                sw = new StringWriter();
                LangExport.serializetoXML(sw, "UTF-8", doc);
                is = new ByteArrayInputStream(sw.toString().getBytes());
                return is;
              } catch (Exception e) {
                throw new ResourceStreamNotFoundException(e);
              }
            }
           
            public void close() throws IOException {
              if (is != null) {
                is.close();
                is = null;
              }
              sw = null;
            }
          });//new FileResourceStream(new File(requestedFile)));
          download.initiate(target);
        }
       
        // repaint the feedback panel so that it is hidden
        target.add(importFeedback);
      }
View Full Code Here

      // Set maximum size controlled by configuration
      setMaxSize(Bytes.bytes(maxBytes));

      // Add a component to download a file without page refresh
      final AjaxDownload download = new AjaxDownload();
      add(download);
      // add an download button
      add(new AjaxButton("download", this) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

          File working_dir = OmFileHelper.getUploadBackupDir();

          String dateString = "backup_" + CalendarPatterns.getTimeForStreamId(new Date());

          File backup_dir = new File(working_dir, dateString);
          File backupFile = new File(backup_dir, dateString + ".zip");

          try {
            getBean(BackupExport.class).performExport(
                backupFile,
                backup_dir,
                includeFilesInBackup.getObject());

            download.setFileName(backupFile.getName());
            download.setResourceStream(new FileResourceStream(backupFile));
            download.initiate(target);
          } catch (Exception e) {
            log.error("Exception on panel backup download ", e);
            uploadFeedback.error(e);
          }
View Full Code Here

        target.add(importFeedback);
      }
    });

    // Add a component to download a file without page refresh
    final AjaxDownload download = new AjaxDownload();
    langForm.add(download);

    langForm.add(new AjaxButton("export"){
      private static final long serialVersionUID = 1L;

      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

        final List<Fieldlanguagesvalues> flvList = getBean(FieldLanguagesValuesDao.class).getMixedFieldValuesList(language.getLanguage_id());

        FieldLanguage fl = getBean(FieldLanguageDao.class).getFieldLanguageById(language.getLanguage_id());
        if (fl != null && flvList != null) {
          download.setFileName(fl.getName() + ".xml");
          download.setResourceStream(new AbstractResourceStream() {
            private static final long serialVersionUID = 1L;
            private StringWriter sw;
            private InputStream is;
           
            public InputStream getInputStream() throws ResourceStreamNotFoundException {
              try {
                Document doc = createDocument(flvList, getBean(FieldLanguagesValuesDao.class).getUntranslatedFieldValuesList(language.getLanguage_id()));
                sw = new StringWriter();
                LangExport.serializetoXML(sw, "UTF-8", doc);
                is = new ByteArrayInputStream(sw.toString().getBytes());
                return is;
              } catch (Exception e) {
                throw new ResourceStreamNotFoundException(e);
              }
            }
           
            public void close() throws IOException {
              if (is != null) {
                is.close();
                is = null;
              }
              sw = null;
            }
          });//new FileResourceStream(new File(requestedFile)));
          download.initiate(target);
        }
       
        // repaint the feedback panel so that it is hidden
        target.add(importFeedback);
      }
View Full Code Here

        target.add(importFeedback);
      }
    });

    // Add a component to download a file without page refresh
    final AjaxDownload download = new AjaxDownload();
    langForm.add(download);

    langForm.add(new AjaxButton("export"){
      private static final long serialVersionUID = 1L;

      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

        final List<Fieldlanguagesvalues> flvList = getBean(FieldLanguagesValuesDao.class).getMixedFieldValuesList(language.getLanguage_id());

        FieldLanguage fl = getBean(FieldLanguageDao.class).getFieldLanguageById(language.getLanguage_id());
        if (fl != null && flvList != null) {
          download.setFileName(fl.getName() + ".xml");
          download.setResourceStream(new AbstractResourceStream() {
            private static final long serialVersionUID = 1L;
            private StringWriter sw;
            private InputStream is;
           
            public InputStream getInputStream() throws ResourceStreamNotFoundException {
              try {
                Document doc = createDocument(flvList, getBean(FieldLanguagesValuesDao.class).getUntranslatedFieldValuesList(language.getLanguage_id()));
                sw = new StringWriter();
                LangExport.serializetoXML(sw, "UTF-8", doc);
                is = new ByteArrayInputStream(sw.toString().getBytes());
                return is;
              } catch (Exception e) {
                throw new ResourceStreamNotFoundException(e);
              }
            }
           
            public void close() throws IOException {
              if (is != null) {
                is.close();
                is = null;
              }
              sw = null;
            }
          });//new FileResourceStream(new File(requestedFile)));
          download.initiate(target);
        }
       
        // repaint the feedback panel so that it is hidden
        target.add(importFeedback);
      }
View Full Code Here

TOP

Related Classes of org.apache.openmeetings.web.util.AjaxDownload

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.