我目前一直在努力在文件上传时更新我的 bean 所以就这样
memberEdit.xhtml
<rich:fileUploadfileUploadListener="#{FileUpload.listener}"
maxFilesQuantity="1" id="upload" immediateUpload="false"
acceptedTypes="jpg, gif, png, bmp, jpeg"allowFlash="false">
<a4j:supportevent="onuploadcomplete"reRender="memberPhotoField"/>
</rich:fileUpload>
<s:decorateid="memberPhotoField"template="layout/edit.xhtml">
<ui:definename="label">Member photo</ui:define>
<h:inputTextareaid="memberPhoto"cols="80"rows="3"
required="true"value="#{memberHome.instance.memberPhoto}"/>
我的文件上传 bean
@Name ("FileUpload")
//getters setters
public void listener(UploadEvent event) throws Exception{
memberHome memberinstance = new CiomemberHome();
//After copying file on hard disk need to update my text field with filename
memberinstance.setphoto(item.getFileName());
// I do get logs correct for item.getFilename
}
我的家实体
@Name("memberHome")
//getter setters....
public void setphoto(String image)
{
log.info("In method set photo");
getInstance().setMemberPhoto(image);
update();
}