Esempio n. 1
0
 /** @see org.apache.wicket.authentication.AuthenticatedWebApplication#init() */
 @Override
 protected void init() {
   super.init();
   getDebugSettings().setDevelopmentUtilitiesEnabled(true);
   // getDebugSettings().setAjaxDebugModeEnabled(true);
   getResourceSettings().setThrowExceptionOnMissingResource(false);
   uploadFolder = new Folder(System.getProperty("java.io.tmpdir"), "wicket-uploads");
   // Ensure folder exists
   uploadFolder.mkdirs();
 }
Esempio n. 2
0
  /**
   * Constructor.
   *
   * @param parameters Page parameters
   */
  public UploadPage(final PageParameters parameters) {
    Folder uploadFolder = getUploadFolder();

    // Create feedback panels
    final FeedbackPanel uploadFeedback = new FeedbackPanel("uploadFeedback");

    // Add uploadFeedback to the page itself
    add(uploadFeedback);

    // Add simple upload form, which is hooked up to its feedback panel by
    // virtue of that panel being nested in the form.
    final FileUploadForm simpleUploadForm = new FileUploadForm("simpleUpload");
    add(simpleUploadForm);

    // Add folder view
    add(new Label("dir", uploadFolder.getAbsolutePath()));
    fileListView =
        new FileListView(
            "fileList",
            new LoadableDetachableModel<List<File>>() {
              @Override
              protected List<File> load() {
                return Arrays.asList(getUploadFolder().listFiles());
              }
            });
    add(fileListView);

    // Add upload form with progress bar
    final FileUploadForm progressUploadForm = new FileUploadForm("progressUpload");

    progressUploadForm.add(
        new UploadProgressBar("progress", progressUploadForm, progressUploadForm.fileUploadField));
    add(progressUploadForm);

    // Add upload form that uses HTML5 <input type="file" multiple />, so it can upload
    // more than one file in browsers which support "multiple" attribute
    final FileUploadForm html5UploadForm = new FileUploadForm("html5Upload");
    add(html5UploadForm);
  }