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("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

    Form uploadForm(final Form form) {
        return new Form("uploadForm") {
            @Override
            protected void onSubmit() {
                FileUpload upload = fileUploadField.getFileUpload();
                if (upload == null) {
                    warn("No file selected.");
                    return;
                }
                ByteArrayOutputStream bout = new ByteArrayOutputStream();

                try {
                    IOUtils.copy(upload.getInputStream(), bout);
                    setRawSLD(new InputStreamReader(new ByteArrayInputStream(bout.toByteArray())));
                    editor.setModelObject(rawSLD);
                } catch (IOException e) {
                    throw new WicketRuntimeException(e);
                }

                // update the style object
                StyleInfo s = (StyleInfo) form.getModelObject();
                if (s.getName() == null || "".equals(s.getName().trim())) {
                    // set it
                    nameTextField.setModelValue(ResponseUtils.stripExtension(upload
                            .getClientFileName()));
                    nameTextField.modelChanged();
                }
            }
        };
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

    protected void onSubmit()
    {
      Iterator<FileUpload> it = uploads.iterator();
      while (it.hasNext())
      {
        final FileUpload upload = 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()
     */
    @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 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);

    assertEquals("pom.xml", fileUpload.getClientFileName());
    assertEquals("text/xml", fileUpload.getContentType());
  }
View Full Code Here

    protected void onSubmit()
    {
      Iterator<FileUpload> it = uploads.iterator();
      while (it.hasNext())
      {
        final FileUpload upload = 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()
     */
    @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 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

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.