【发布时间】:2026-01-14 07:40:01
【问题描述】:
我正在使用来自 RichFaces4 的 <rich:fileUpload />,如您所见 here。
但正如你所见,用户可以选择很多图片,但我希望他只能选择一张图片。
上传完成后如何调用托管 bean 中的方法(将图像发送到我的 Amazon S3 存储桶)?
编辑:
<ui:composition>
<h:outputStylesheet>
.top {
vertical-align: top;
}
.info {
height: 202px;
overflow: auto;
}
.rf-fu-lst {
height: 60px;
}
.rf-fu-itm {
border: 0;
}
</h:outputStylesheet>
<h:outputScript target="head">
jQuery.extend(RichFaces.ui.FileUpload.prototype, {
__updateButtons: function() {
if (!this.loadableItem && this.list.children(".rf-fu-itm").size()) {
if (this.items.length) {
this.uploadButton.css("display", "inline-block");
this.addButton.hide();
} else {
this.uploadButton.hide();
this.addButton.css("display", "inline-block");
}
} else {
this.uploadButton.hide();
this.addButton.css("display", "inline-block");
}
}
});
</h:outputScript>
<h:form id="form_user_upload_picture" >
<h:panelGrid columns="2" columnClasses="top, top">
<rich:fileUpload
id="upload"
fileUploadListener="#{user_file_upload.listener}"
acceptedTypes="jpg, gif, png, bmp"
addLabel="Adicionar"
clearAllLabel="Limpar todas"
clearLabel="limpar"
deleteLabel="apagar"
doneLabel="upload realizado"
sizeExceededLabel="arquivo muito grande, tente um arquivo de tamanho menor"
serverErrorLabel="ocorreu um erro em nosso servidor, tente novamente por favor"
uploadLabel="Enviar">
<a4j:ajax event="uploadcomplete" execute="@none" render="picture" />
</rich:fileUpload>
</h:panelGrid>
</h:form>
</ui:composition>
【问题讨论】:
标签: jsf file-upload jsf-2 richfaces