• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FileBean类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.sourceforge.stripes.action.FileBean的典型用法代码示例。如果您正苦于以下问题:Java FileBean类的具体用法?Java FileBean怎么用?Java FileBean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileBean类属于net.sourceforge.stripes.action包,在下文中一共展示了FileBean类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: saveUpload

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
protected void saveUpload(HttpServletRequest req) {
    StripesRequestWrapper stripesRequest =
        StripesRequestWrapper.findStripesWrapper(req);
    final FileBean fileBean = stripesRequest.getFileParameterValue(inputName);

    if (fileBean != null) {
        try {
            newBlob(fileBean);
        } catch (IOException e) {
            logger.error("Could not read upload", e);
            forgetBlob();
            blobError = getText("elements.error.field.fileblob.uploadFailed");
            try {
                fileBean.delete();
            } catch (IOException e1) {
                logger.error("Could not delete FileBean", e1);
            }
        }
    } else {
        logger.debug("An update of a blob was requested, but nothing was uploaded. The previous value will be kept.");
        keepOldBlob(req);
    }
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:24,代码来源:AbstractBlobField.java


示例2: newBlob

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
protected void newBlob(final FileBean fileBean) throws IOException {
    blob = new Blob(generateNewCode()) {
        @Override
        public void dispose() {
            super.dispose();
            try {
                fileBean.delete();
            } catch (IOException e) {
                logger.warn("Could not delete file bean", e);
            }
        }
    };
    blob.setInputStream(fileBean.getInputStream());
    blob.setFilename(fileBean.getFileName());
    blob.setContentType(fileBean.getContentType());
    blob.setCreateTimestamp(new DateTime());
    blob.setPropertiesLoaded(true);
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:19,代码来源:AbstractBlobField.java


示例3: getFileParameterValue

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
/**
 * Responsible for constructing a FileBean object for the named file parameter. If there is no
 * file parameter with the specified name this method should return null.
 *
 * @param name the name of the file parameter
 * @return a FileBean object wrapping the uploaded file
 */
public FileBean getFileParameterValue(String name) {
    File file = this.multipart.getFile(name);
    if (file != null) {
        return new FileBean(file,
                            this.multipart.getContentType(name),
                            this.multipart.getOriginalFileName(name),
                            this.charset);
    }
    else {
        return null;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:CosMultipartWrapper.java


示例4: getFileParameterValue

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
/**
 * Returns a FileBean representing an uploaded file with the form field name = "name".
 * If the form field was present in the request, but no file was uploaded, this method will
 * return null.
 *
 * @param name the form field name of type file
 * @return a FileBean if a file was actually submitted by the user, otherwise null
 */
public FileBean getFileParameterValue(String name) {
    if (this.multipart != null) {
        return this.multipart.getFileParameterValue(name);
    }
    else {
        return null;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:StripesRequestWrapper.java


示例5: getFileParameterValue

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
/**
 * Responsible for constructing a FileBean object for the named file parameter. If there is no
 * file parameter with the specified name this method should return null.
 *
 * @param name the name of the file parameter
 * @return a FileBean object wrapping the uploaded file
 */
public FileBean getFileParameterValue(String name) {
    final FileItem item = this.files.get(name);

    if (item == null
            || ((item.fileName == null || item.fileName.length() == 0) && item.size == 0)) {
        return null;
    }
    else {
        // Attempt to ensure the file name is just the basename with no path included
        String filename = item.fileName;
        int index;
        if (WINDOWS_PATH_PREFIX_PATTERN.matcher(filename).find())
            index = filename.lastIndexOf('\\');
        else
            index = filename.lastIndexOf('/');
        if (index >= 0 && index + 1 < filename.length() - 1)
            filename = filename.substring(index + 1);

        // Use an anonymous inner subclass of FileBean that overrides all the
        // methods that rely on having a File present, to use the FileItem
        // created by commons upload instead.
        return new FileBean(null, item.contentType, filename, this.charset) {
            @Override
            public long getSize() {
                return item.size;
            }

            @Override
            public InputStream getInputStream() throws IOException {
                return item.contents.getInputStream();
            }

            @Override
            public void delete() throws IOException {
                item.contents.dispose();
            }
        };
    }
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:47,代码来源:StreamingCommonsMultipartWrapper.java


示例6: getFileParameterValue

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
/**
 * Responsible for constructing a FileBean object for the named file parameter. If there is no
 * file parameter with the specified name this method should return null.
 *
 * @param name the name of the file parameter
 * @return a FileBean object wrapping the uploaded file
 */
public FileBean getFileParameterValue(String name) {
    final FileItem item = this.files.get(name);
    if (item == null
            || ((item.getName() == null || item.getName().length() == 0) && item.getSize() == 0)) {
        return null;
    }
    else {
        // Attempt to ensure the file name is just the basename with no path included
        String filename = item.getName();
        int index;
        if (WINDOWS_PATH_PREFIX_PATTERN.matcher(filename).find())
            index = filename.lastIndexOf('\\');
        else
            index = filename.lastIndexOf('/');
        if (index >= 0 && index + 1 < filename.length() - 1)
            filename = filename.substring(index + 1);

        // Use an anonymous inner subclass of FileBean that overrides all the
        // methods that rely on having a File present, to use the FileItem
        // created by commons upload instead.
        return new FileBean(null, item.getContentType(), filename, this.charset) {
            @Override public long getSize() { return item.getSize(); }

            @Override public InputStream getInputStream() throws IOException {
                return item.getInputStream();
            }

            @Override public void save(File toFile) throws IOException {
                try {
                    item.write(toFile);
                    delete();
                }
                catch (Exception e) {
                    if (e instanceof IOException) throw (IOException) e;
                    else {
                        IOException ioe = new IOException("Problem saving uploaded file.");
                        ioe.initCause(e);
                        throw ioe;
                    }
                }
            }

            @Override
            public void delete() throws IOException { item.delete(); }
        };
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:55,代码来源:CommonsMultipartWrapper.java


示例7: getUpload

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public FileBean getUpload() {
    return upload;
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:4,代码来源:FileManagerCKEditorAction.java


示例8: setUpload

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public void setUpload(FileBean upload) {
    this.upload = upload;
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:4,代码来源:FileManagerCKEditorAction.java


示例9: getImageFile

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public FileBean getImageFile() {
    return imageFile;
}
 
开发者ID:nordpos-mobi,项目名称:product-catalog,代码行数:4,代码来源:ProductChangeActionBean.java


示例10: setImageFile

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public void setImageFile(FileBean imageFile) {
    this.imageFile = imageFile;
}
 
开发者ID:nordpos-mobi,项目名称:product-catalog,代码行数:4,代码来源:ProductChangeActionBean.java


示例11: getItems

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public List<FileBean> getItems() {
	return items;	
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:4,代码来源:UploadInvoice.java


示例12: setItems

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public void setItems(List<FileBean> fbeans) {
	items = fbeans;
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:4,代码来源:UploadInvoice.java


示例13: upload

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public Resolution upload() throws Exception {
	Invoice invc = null;
	capturedCount = 0;
	final int nItems = (getItems()==null ? 0 : getItems().size());
	if (nItems>0) {
		Log.out.debug("InvoiceUpload "+String.valueOf(nItems)+" items found");
		try {
			connect(getSessionAttribute("nickname"), getSessionAttribute("password"));

			Dms oDms = getSession().getDms();
			Document rcpt = oDms.getDocument(getRecipientTaxPayer());
			String sTaxPayerId = rcpt.type().name().equals("TaxPayer") ? getRecipientTaxPayer() : getSessionAttribute("taxpayer_docid");
			TaxPayer txpy = new TaxPayer(getSession().getDms(), sTaxPayerId);

			Invoices invs = txpy.invoices(getSession());
			
			invc = invs.create(getSession(), getSessionAttribute("user_uuid"), getServiceFlavor(),
							   sTaxPayerId, getBillerTaxPayer(), getRecipientTaxPayer());
			capureddocid = invc.id();
			
			for (FileBean attachment : getItems()) {
				if (attachment != null) {
					if (attachment.getSize() > 0) {
						InvoicePage page = invc.createPage(getSession(), attachment.getInputStream(), ++capturedCount, attachment.getFileName());
						if (capturedCount==1) {
							capuredpage1 = page.id();
						}
						attachment.delete();
					} else {
					  ValidationError error = new SimpleError(attachment.getFileName()+ " is not a valid file." );
					  getContext().getValidationErrors().add("items" , error);
				  }
				}
		    } // next
			disconnect();
			Log.out.debug("Done uploading items");
			if (capturedCount>0) {
				ThumbnailCreator.createThumbnailFor(capureddocid, capuredpage1);
			}
		} catch (Exception e) {
			Log.out.error("InvoiceUpload.upload() "+e.getClass().getName()+" "+e.getMessage(), e);
			getContext().getMessages().add(new SimpleMessage("ERROR "+e.getMessage(), items));		  
		} finally { close(); }
		
	} else {
		Log.out.debug("InvoiceUpload no items found");
	}
	if (invc==null)
		return new RedirectResolution("/error.jsp");
	if (invc.getServiceFlavor().equals(CaptureServiceFlavor.BASIC))
		return new ForwardResolution("EditInvoice.action?id="+invc.id());
	else
		return new ForwardResolution(FORM);
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:55,代码来源:UploadInvoice.java


示例14: setItems

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public void setItems(List<FileBean> fbeans) {
	items =  fbeans;
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:4,代码来源:UploadBillNote.java


示例15: upload

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public Resolution upload() throws Exception {
	String sFwd;
	Ticket tckt = null;
	BillNote bill = null;
	setCapturedCount(0);
	final int nItems = (getItems()==null ? 0 : getItems().size());
	if (nItems>0) {
		Log.out.debug("UploadBillNote "+String.valueOf(nItems)+" items found");
		try {
			connect(getSessionAttribute("nickname"), getSessionAttribute("password"));

			TaxPayer txpy = new TaxPayer(getSession().getDms(), getRecipientTaxPayer());

			bill = txpy.billnotes(getSession()).forConcept(getSession(), getConcept(), getEmployee());
			setCapturedPage1("");

			for (FileBean attachment : getItems()) {
				if (attachment != null) {
					if (attachment.getSize() > 0) {
						if (tckt==null) {
							tckt = bill.createTicket(getSession(), getAccount());
							setId(tckt.id());
							FlashScope oFscope = FlashScope.getCurrent(getContext().getRequest(), true);
							oFscope.put("ticket_docid", tckt.id());
						}
						TicketNote note = tckt.createNote(getSession(), attachment.getInputStream(), incCapturedCount(), attachment.getFileName());
						if (getCapturedPage1().length()==0) setCapturedPage1(note.id());
						attachment.delete();
					} else {
					  ValidationError error = new SimpleError(attachment.getFileName()+ " is not a valid file." );
					  getContext().getValidationErrors().add("items" , error);
				  }
				}
		    } // next
			disconnect();
			if (getCapturedCount()>0)
				ThumbnailCreator.createThumbnailFor(getId(), getCapturedPage1());				
			sFwd = "EditBillNote.action?id="+tckt.id();
		} catch (IllegalStateException e) {
			Log.out.error("BillNoteUpload.upload() "+e.getClass().getName()+" "+e.getMessage(), e);
			getContext().getMessages().add(new SimpleMessage("ERROR "+e.getMessage(), items));
			sFwd = "error.jsp?e=couldnotloadticket";
		} finally { close(); }
		
	} else {
		Log.out.debug("UploadBillNote no items found");
		sFwd = "error.jsp?e=couldnotloadticket";
	}
	return new ForwardResolution(sFwd);
}
 
开发者ID:sergiomt,项目名称:zesped,代码行数:51,代码来源:UploadBillNote.java


示例16: getFileParameterValue

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
/**
 * Responsible for constructing a FileBean object for the named file parameter. If there is
 * no file parameter with the specified name this method should return null.
 *
 * @param name the name of the file parameter
 * @return a FileBean object wrapping the uploaded file
 */
FileBean getFileParameterValue(String name);
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:MultipartWrapper.java


示例17: getNewAttachment

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public FileBean getNewAttachment() { return newAttachment; } 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:2,代码来源:SingleBugActionBean.java


示例18: setNewAttachment

import net.sourceforge.stripes.action.FileBean; //导入依赖的package包/类
public void setNewAttachment(FileBean newAttachment) { this.newAttachment = newAttachment; } 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:2,代码来源:SingleBugActionBean.java



注:本文中的net.sourceforge.stripes.action.FileBean类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Classes类代码示例发布时间:2022-05-22
下一篇:
Java AndDown类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap