1
我試圖重新渲染一個文件(照片)上傳後的幾個組件,但由於某種原因,上傳完成後,組件不會被重新渲染。任何人都可以請幫忙? 我在運行Tomcat 6應用程序的64位Windows 7機器上使用Java 1.6 JSF 1.2 Richfaces 3.3.3 Seam 2.2GA;RichFaces fileUpload notre rendering
<h:panelGrid columns="2" id="photoGrid"
rendered="#{not signUpAction.fileUpRendered}" styleClass="standard">
<h:graphicImage value="#{signUpAction.imageUrl}" width="150" height="171" />
<a4j:region>
<a4j:commandLink id="remove" action="#{signUpAction.removePhoto}"
reRender="a4jphotoUpload" value="Remove Photo" />
</a4j:region>
</h:panelGrid>
<h:panelGroup id="photoGroup" rendered="#{signUpAction.fileUpRendered}">
<rich:fileUpload maxFilesQuantity="1"
fileUploadListener="#{signUpAction.listener}"
addControlLabel="Add a photo..." allowFlash="true"
id="photoUploadWidget" autoclear="true"
listHeight="1" immediateUpload="true" acceptedTypes="jpg,jpeg,png,gif">
<f:facet name="label">
<h:outputText value="{_KB}KB from {KB}KB uploaded --- {mm}:{ss}" />
</f:facet>
<a4j:support event="onuploadcomplete" reRender="photoGrid,photoGroup"/>
</rich:fileUpload>
</h:panelGroup>
我終於找到了一種解決方案,我稱之爲A4J:jsFunction用於重新呈現組件和從onuploadcomplete事件調用它(見下面的代碼)
<h:panelGroup id="photoGroup" rendered="#{signUpAction.fileUpRendered}">
<rich:fileUpload maxFilesQuantity="1" fileUploadListener="#{signUpAction.listener}"
addControlLabel="Add a photo..."
id="photoUploadWidget" autoclear="true" onuploadcomplete="reloadPhotoPanel()" onfileuploadcomplete="reloadPhotoPanel()"
listHeight="1" immediateUpload="true" acceptedTypes="jpg,jpeg,png,gif">
</rich:fileUpload>
</h:panelGroup>
</a4j:outputPanel>
<a4j:jsFunction id="reloadPhotoPanel" name="reloadPhotoPanel" reRender="photoPanel,photoGrid,photoGroup" />
感謝Luiggi,我想你的建議都沒有用,我仍然有同樣的問題是什麼。 –
@KennethNjendu答案更新。我注意到''也應該像這樣封閉。 –