File upload Primefaces上载文件-上载后图像不刷新

File upload Primefaces上载文件-上载后图像不刷新,file-upload,primefaces,jsf-2.2,File Upload,Primefaces,Jsf 2.2,上传图像后我遇到了一个问题。上载时不会刷新图像。bean是会话范围的,上传后我需要手动刷新页面以查看新图像。上传图像/文件后,如何自动刷新图形图像?多谢各位 以下代码可以成功上载图像,但前一个图像仍然可见,而新图像只有在刷新后才能可见: 平台: JSF2.2 ,tomcat 7.37 ,primefaces 5.0 <h:form id="form" enctype="multipart/form-data"> <p:growl id="growl_1" sh

上传图像后我遇到了一个问题。上载时不会刷新图像。bean是会话范围的,上传后我需要手动刷新页面以查看新图像。上传图像/文件后,如何自动刷新图形图像?多谢各位

以下代码可以成功上载图像,但前一个图像仍然可见,而新图像只有在刷新后才能可见:

平台: JSF2.2 ,tomcat 7.37 ,primefaces 5.0

 <h:form id="form" enctype="multipart/form-data">
        <p:growl id="growl_1" showDetail="true"/>    

  <p:panelGrid id="pg_photo" 
               style="margin-bottom:10px; 
               width: 50em" 
               styleClass="panelGridCenter"> 
            <f:facet name="header">
                <p:row>
                    <p:column>
                        <p:graphicImage 
                            id="gi_etud" 
                            width="150" 
                            height="120" 
                            value="#{etudiantProfilView.imageEtudAsStream}"/>
                    </p:column>
                    <p:column>
                        <p:fileUpload id="fu_photo" 
                                      value="#{etudiantProfilView.imageEtudUF}" 
                                      mode="advanced"
                                      dragDropSupport="true"
                                      fileLimit="10"
                                      sizeLimit="100000"
                                      allowTypes="/(\.|\/)(gif|jpg|jpeg|gif|png|PNG|GIF|JPG|JPEG)$/"
                                      auto="true"
                                      update="growl_1 gi_etud"
                                      fileUploadListener="#{etudiantProfilView.imageUploadListener}"
                                      >
                        </p:fileUpload>
                    </p:column>
                </p:row>
            </f:facet>
        </p:panelGrid>
 </h:form>

我已通过在uploadFile组件的“oncomplete”属性中添加“reload”操作解决了刷新问题:

  <p:fileUpload id="fu_photo" value="#{etudiantProfilView.imageEtudUF}" 
                                      mode="advanced"
                                      dragDropSupport="true"
                                      fileLimit="10"
                                      sizeLimit="200000"
                                      allowTypes="/(\.|\/)(gif|jpg|jpeg|gif|png|PNG|GIF|JPG|JPEG)$/"
                                      auto="true"
                                      update="@form"
                                      oncomplete="window.location.reload();"
                                      fileUploadListener="#{etudiantProfilView.imageUploadListener}"
                                      >
                        </p:fileUpload>

  <p:fileUpload id="fu_photo" value="#{etudiantProfilView.imageEtudUF}" 
                                      mode="advanced"
                                      dragDropSupport="true"
                                      fileLimit="10"
                                      sizeLimit="200000"
                                      allowTypes="/(\.|\/)(gif|jpg|jpeg|gif|png|PNG|GIF|JPG|JPEG)$/"
                                      auto="true"
                                      update="@form"
                                      oncomplete="window.location.reload();"
                                      fileUploadListener="#{etudiantProfilView.imageUploadListener}"
                                      >
                        </p:fileUpload>