Package org.apache.wicket.markup.html.form.upload

Examples of org.apache.wicket.markup.html.form.upload.FileUpload


      @Override
      protected void onSubmit()
      {
        // display uploaded info
        info("Text: " + text.getModelObject());
        FileUpload upload = file.getFileUpload();
        if (upload == null)
        {
          info("No file uploaded");
        }
        else
        {
          info("File-Name: " + upload.getClientFileName() + " File-Size: " +
            Bytes.bytes(upload.getSize()).toString());
        }
      }
    };
    form.setMaxSize(Bytes.megabytes(1));
    add(form);
View Full Code Here


    assertNotNull(domainObject);
    assertNotNull(domainObject.getText());
    assertEquals("Mock value", domainObject.getText());

    FileUpload fileUpload = page.getFileUpload();
    assertNotNull(fileUpload);

    assertTrue("setFile failed, no upload content detected.", fileUpload.getBytes().length > 0);
    assertEquals("pom.xml", fileUpload.getClientFileName());
    assertEquals("text/xml", fileUpload.getContentType());
  }
View Full Code Here

    assertNotNull(domainObject);
    assertNotNull(domainObject.getText());
    assertEquals("Mock value", domainObject.getText());

    FileUpload fileUpload = page.getFileUpload();
    assertNotNull(fileUpload);

    assertTrue("uploaded content does not have the right size, expected 428, got " +
      fileUpload.getBytes().length, fileUpload.getBytes().length == 428);
    assertEquals("bg.jpg", fileUpload.getClientFileName());
    assertEquals("image/jpeg", fileUpload.getContentType());
  }
View Full Code Here

      @Override
      protected void onSubmit()
      {
        // display uploaded info
        info("Text: " + text.getModelObject());
        FileUpload upload = file.getFileUpload();
        if (upload == null)
        {
          info("No file uploaded");
        }
        else
        {
          info("File-Name: " + upload.getClientFileName() + " File-Size: " +
            Bytes.bytes(upload.getSize()).toString());
        }
      }
    };
    form.setMaxSize(Bytes.megabytes(1));
    add(form);
View Full Code Here

      add(new AjaxButton("upload", this) {
        private static final long serialVersionUID = 839803820502260006L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
          FileUpload upload = fileUploadField.getFileUpload();
          try {
            if (upload == null || upload.getInputStream() == null) {
              uploadFeedback.error("File is empty");
              return;
            }
            Application.getBean(BackupImportController.class)
                .performImport(upload.getInputStream());
          } catch (IOException e) {
            log.error("IOException on panel backup upload ", e);
            uploadFeedback.error(e);
          } catch (Exception e) {
            log.error("Exception on panel backup upload ", e);
View Full Code Here

    protected void onSubmit()
    {
      Iterator it = uploads.iterator();
      while (it.hasNext())
      {
        final FileUpload upload = (FileUpload)it.next();
        // Create a new file
        File newFile = new File(getUploadFolder(), upload.getClientFileName());

        // Check new file, delete if it allready existed
        checkFileExists(newFile);
        try
        {
          // Save to new file
          newFile.createNewFile();
          upload.writeTo(newFile);

          MultiUploadPage.this.info("saved file: " + upload.getClientFileName());
        }
        catch (Exception e)
        {
          throw new IllegalStateException("Unable to write file");
        }
View Full Code Here

    /**
     * @see org.apache.wicket.markup.html.form.Form#onSubmit()
     */
    protected void onSubmit()
    {
      final FileUpload upload = fileUploadField.getFileUpload();
      if (upload != null)
      {
        // Create a new file
        File newFile = new File(getUploadFolder(), upload.getClientFileName());

        // Check new file, delete if it allready existed
        checkFileExists(newFile);
        try
        {
          // Save to new file
          newFile.createNewFile();
          upload.writeTo(newFile);

          UploadPage.this.info("saved file: " + upload.getClientFileName());
        }
        catch (Exception e)
        {
          throw new IllegalStateException("Unable to write file");
        }
View Full Code Here

    assertNotNull(domainObject);
    assertNotNull(domainObject.getText());
    assertEquals("Mock value", domainObject.getText());

    FileUpload fileUpload = page.getFileUpload();
    assertNotNull(fileUpload);

    assertTrue("setFile failed, no upload content detected.", fileUpload.getBytes().length > 0);
    assertEquals("pom.xml", fileUpload.getClientFileName());
    assertEquals("text/xml", fileUpload.getContentType());
  }
View Full Code Here

    assertNotNull(domainObject);
    assertNotNull(domainObject.getText());
    assertEquals("Mock value", domainObject.getText());

    FileUpload fileUpload = page.getFileUpload();
    assertNotNull(fileUpload);

    assertTrue("uploaded content does not have the right size, expected 428, got " +
      fileUpload.getBytes().length, fileUpload.getBytes().length == 428);
    assertEquals("bg.jpg", fileUpload.getClientFileName());
    assertEquals("image/jpeg", fileUpload.getContentType());
  }
View Full Code Here

    fileUploadField.add(new AjaxFormSubmitBehavior(form, "onchange") {
      private static final long serialVersionUID = 2160216679027859231L;

      @Override
      protected void onSubmit(AjaxRequestTarget target) {
        FileUpload fu = fileUploadField.getFileUpload();
        if (fu != null) {
          StoredFile sf = new StoredFile(fu.getClientFileName());
          if (sf.isImage()) {
            boolean asIs = sf.isAsIs();
            try {
              //FIXME need to work with InputStream !!!
              getBean(GenerateImage.class)
                .convertImageUserProfile(fu.writeToTempFile(), userId, asIs);
            } catch (Exception e) {
              // TODO display error
              e.printStackTrace();
            }
          } else {
View Full Code Here

TOP

Related Classes of org.apache.wicket.markup.html.form.upload.FileUpload

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.