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

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


    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


    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
                    public void onSubmit()
                    {
                        final FileUpload upload = fileUpload;
                        final String userName = getPortletRequest()
                                .getUserPrincipal().getName();
                        String pathSeparator = System
                                .getProperty("file.separator");
                        boolean copyIds = getCopyIdsOnImport();
                        boolean success = false;
                        if (upload != null)
                        {
                            try
                            {
                                PageManager pageManager = getServiceLocator()
                                        .getPageManager();
                                String fileName = upload.getClientFileName();
                                String fileType = fileExt(upload.getClientFileName());
                                cleanUserFolder(userName);
                                String usrFolder = getTempFolder(userName);
                                String destPath = node.getNodePath();
                                upload.writeTo(new File(usrFolder
                                        + pathSeparator
                                        + upload.getClientFileName()));
                                // File writed in temp folder
                                if (fileType != null && !fileType.equals("")
                                        && fileName != null
                                        && !fileName.equals("")
                                        && destPath != null
View Full Code Here

        /* (non-Javadoc)
         * @see org.apache.wicket.markup.html.form.Form#onSubmit()
         */
        @Override
        protected void onSubmit() {
            final FileUpload fileUpload = fileUploadField.getFileUpload();
            Item item = (Item) getModelObject();
            User user = getPrincipal();
            if (editMode) {
                getJtrac().updateItem(item, user);
            } else {
View Full Code Here

            super.validate();
        }
       
        @Override
        protected void onSubmit() {
            final FileUpload fileUpload = fileUploadField.getFileUpload();
            History history = (History) getModelObject();
            User user = JtracSession.get().getUser();
            history.setLoggedBy(user);
            getJtrac().storeHistoryForItem(itemId, history, fileUpload);
            setResponsePage(ItemViewPage.class, new PageParameters("0=" + history.getRefId()));
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

    public IsisClobPanel(final String id, final ScalarModel model) {
        super(id, model);
    }

    protected Clob getBlobOrClobFrom(final List<FileUpload> fileUploads) {
        final FileUpload fileUpload = fileUploads.get(0);
        final String contentType = fileUpload.getContentType();
        final String clientFileName = fileUpload.getClientFileName();
        final String str = new String(fileUpload.getBytes(), CHARSET);
        final Clob blob = new Clob(clientFileName, contentType, str);
        return blob;
    }
View Full Code Here

        super(id, model);
    }

   
    protected Blob getBlobOrClobFrom(final List<FileUpload> fileUploads) {
        final FileUpload fileUpload = fileUploads.get(0);
        final String contentType = fileUpload.getContentType();
        final String clientFileName = fileUpload.getClientFileName();
        final byte[] bytes = fileUpload.getBytes();
        final Blob blob = new Blob(clientFileName, contentType, bytes);
        return blob;
    }
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.