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

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


    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

    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

    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

            this.clearMessages();

            File tempDir = new File(System.getProperty("java.io.tmpdir"));
            File userTempDir = new File(tempDir, getPortletRequest().getUserPrincipal().getName());

            final FileUpload upload = ((FileUploadField) this.get("importFile")).getFileUpload();

            if (upload == null)
            {
                this.errorMessage = createMessage("import.message.nofile", null);
                return;
            }

            synchronized (this)
            {
                try
                {
                    if (!userTempDir.isDirectory())
                    {
                        userTempDir.mkdirs();
                    }

                    final File importFile = new File(userTempDir, upload.getClientFileName());
                    this.fileName = importFile.getCanonicalPath();

                    if (importFile.exists())
                    {
                        importFile.delete();
                    }

                    upload.writeTo(importFile);
                }
                catch (IOException ioe)
                {
                    this.errorMessage = createMessage("import.message.exception", new Object[]
                    { upload.getClientFileName(), ioe.getMessage()});
                }

                try
                {
                    getJetspeedSerializer().importData(this.fileName, this.settings);

                    this.infoMessage = createMessage("import.message.success", new Object[]
                    { this.fileName});
                }
                catch (SerializerException se)
                {
                    this.errorMessage = createMessage("import.message.exception", new Object[]
                    { upload.getClientFileName(), se.getMessage()});
                }
            }
        }
View Full Code Here

     * @see org.apache.wicket.markup.html.form.Form#onSubmit()
     */
    @Override
    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 already 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

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.