- publicvoiduploadListener(UploadEventevent){
-
try{
- UploadItemitem=event.getUploadItem();
- StringfileName=item.getFileName();
-
Stringfilepath=FacesUtil.getServletContext().getRealPath("/")
-
+"UploadFile/";
-
Filefile=newFile(filepath,fileName);
-
FileInputStreamfis=newFileInputStream(item.getFile());
-
FileOutputStreamout=newFileOutputStream(file);
-
intbytes=0;
-
byte[]bteFile=newbyte[1024];
-
while((bytes=fis.read(bteFile))!=-1){
-
out.write(bteFile,0,bytes);
- }
-
FacesUtils.addErrorMessage("文件上传成功!"+filepath+fileName);
-
}catch(Exceptione){
-
FacesUtils.addErrorMessage(("文件上传失败!");
- }
- }
public void uploadListener(UploadEvent event) {
try {
UploadItem item = event.getUploadItem();
String fileName = item.getFileName();
String filepath = FacesUtil.getServletContext().getRealPath("/")
+ "UploadFile/";
File file = new File(filepath, fileName);
FileInputStream fis = new FileInputStream(item.getFile());
FileOutputStream out = new FileOutputStream(file);
int bytes = 0;
byte[] bteFile = new byte[1024];
while ((bytes = fis.read(bteFile)) != -1) {
out.write(bteFile, 0, bytes);
}
FacesUtils.addErrorMessage("文件上传成功!"+filepath+fileName);
} catch (Exception e) {
FacesUtils.addErrorMessage(("文件上传失败!");
}
}
- <h:panelGroup>
-
<h:outputTextvalue="上传头像"></h:outputText>
-
<rich:spacerheight="3"/>
-
<rich:fileUploadfileUploadListener="#{fileUploadBean.uploadListener}"
-
maxFilesQuantity="5"
-
autoclear="false"
-
addControlLabel="添加图片"
-
uploadControlLabel="上传"
-
clearAllControlLabel="清除所有"
-
clearControlLabel="清除"
-
cancelEntryControlLabel="取消"
-
stopControlLabel="停止"
-
stopEntryControlLabel="停止"noDuplicate="true"
-
listHeight="50"
-
listWidth="515"
-
style="height:100;"
-
id="upload"
-
acceptedTypes="jpg,gif,png,bmp">
- </rich:fileUpload>
-
<h:outputTextvalue="支持JPG、JPEG、GIF、BMP和PNG文件格式,最大4M。">
- </h:outputText>
- </h:panelGroup>
分享到:
相关推荐
详细的介绍了RichFaces中的Ajax组件的使用配置以及组件的使用方法。是为初学者了解ajax组件提供一点方便
Richfaces标签 简介Richfaces标签相关内容 初学者认知
richfaces标签学习笔记richfaces标签学习笔记richfaces标签学习笔记richfaces标签学习笔记
这是richfaces 3.3.1的用户手册PDF版
教会如何使用richfaces,及richfaces应用
Richfaces组件使用指南、richfaces手册(很详细、很全面的教程)
关于richfaces的一些比较好的资料,希望大家看了能有收获
RichFaces组件简介,复合组件,日期控件,Ajax标签, 轻松实现。RichFaces组件简介,复合组件,日期控件,Ajax标签, 轻松实现。RichFaces组件简介,复合组件,日期控件,Ajax标签, 轻松实现。
jboss的richfaces-ui-3.2.1.GA 同样受大小的限制,只上传jar包
RichFaces_3.3.3_TLD.chm
使用richfaces需要用到的jar包! commons-beanutils-1.7.0.jar,commons-codec-1.3.jar,commons-collections-3.2.jar,commons-digester-1.8.jar,commons-discovery-0.4.jar,commons-el-1.0.jar,commons-...
richfaces中文开发文档 纯中文 适合维护老项目的人
richfaces3.1.4版的demo,运行在jboss和tomcat5.5下
Richfaces ShowCase离线包,可直接在tomcat下部署,含在线演示例子。
RichFaces4.5 JavaApi JSApi API文档 英文版
richfaces4.0所需的jar包,richfaces4.0所需的jar包,richfaces4.0所需的jar包,
内带最新的richfaces jar包,轻松实现多文件的上传
Richfaces3.3.3常用组件使用手册 便于学习Richfaces和a4j和jsf框架 很好很实用
本文档主要根据richfaces3.3.3 用户手册和demo 编写。 Richfaces 下载地址http://www.jboss.org/richfaces/download/stable。 demo 下载地址http://www.jboss.org/richfaces/demos。
richfaces-distribution-4.5.8.Final的richfaces-showcase的部署包