QFaces1.2--ajax mode, file Upload component with progress bar fileupload (for JSF)

Source: Internet
Author: User
Tags file upload

This is the 4th component of the Qfaces, Ajax way with the progress bar file upload component, I hope that every important component to upgrade a version, hehe! This version also fixes the Ajax compatibility problem under IE6. After introducing this component, you intend to introduce how to use qfaces from Define your own Ajax components, hopefully, this enhanced framework will help some people who like JSF. Later versions of the upgrade may not be so fast, or consider compatibility with facelets, and fix some of the possible errors, as well as open source plans, and then continue to maintain and add some of the more common and practical components, Pay attention to the development of JSF2.0 and so on.

Well, here's a new member of the Qfaces: FileUpload, the following is a screenshot of the use of the process, for the interface I do not have too high requirements, there is no open related properties, or simple to use as the first element, if you customize components, you can make a more cool or more fancy interface out, hehe!

The use of components is simple:

<q:fileupload process= "#{fileuploadbean.process}"/>

The following is the HTML complete code, which should be noted that the component cannot be placed inside the form because the component renders its own form label:

<f:view>
<meta http-equiv="Content-Type" content="text/html; charset=UTF- 8">
<title>FileUpload Demo</title>
<body>
<q:fileUpload process="#{FileUploadBean.process}"/>
</body>
</f:view>

Background beans as long as binding a processing method can be, simple operation processing, save the file to the local hard disk, the following is the demo in the example:

public boolean process(QFile qfile) throws Exception {
// 检查并创建用于保存上传文件的目录
File fileDir = new File("c:\\my-qfaces-upload-file");
if (!fileDir.exists()) {
fileDir.mkdirs();
}
// 创建文件对象,并将上传的文件保存到该对象.
File upfile = new File(fileDir.getAbsolutePath() + "\\" + qfile.getFilename ());
qfile.save(upfile);
return true;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.