我使用RichFaces4的<rich:fileUpload />
,如您所見here。 但正如你所看到的那樣,用戶可以選擇很多圖片,但我希望他可以選擇一張圖片。如何限制RichFaces 4 rich:fileUpload單個文件上傳?
上傳完成後,如何在我的託管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>
我上傳到S3後,文件上傳完成後,謝謝。 但是現在我試圖只上傳一個文件,正如你所說的,但給我一個錯誤:實體名稱必須緊跟在實體引用中的'&'後面。 –
你不應該把JavaScript代碼放在一個XML文件中,而是放在一個JS文件中:)用'&'替換'&'。 – BalusC
它適合隊友,謝謝! –