【问题标题】:Primefaces fileUpload only works firts timePrimefaces fileUpload 仅第一次有效
【发布时间】:2014-03-14 19:28:00
【问题描述】:

当我上传文件时,我需要更新一些组件。它只在我第一次使用时才有效。

XHTML:

<p:fileUpload id="Uploader" fileUploadListener="#{cc.attrs.updateImageAction}"  
                    mode="advanced"
                    update="#{cc.id}:updatableElements #{cc.attrs.ajaxRender} #{cc.attrs.ajaxRenderCropDialog}"
                    auto="true" 
                    multiple="false" 
                    sizeLimit="#{cc.attrs.sizeLimit}"   
                    allowTypes="#{imageManagerServiceBean.imageFileAllowedTypesRegEx}"
                    label="#{messages['generic.images.select']}"
                    uploadLabel="#{messages['generic.images.upload']}"
                    cancelLabel="#{messages['generic.images.cancel']}"
                    invalidSizeMessage="#{cc.attrs.invalidFileSizeMessage}"
                    invalidFileMessage="#{messages['generic.images.invalidtype']}"
                    >
            </p:fileUpload>

有什么想法吗?

【问题讨论】:

  • 第二次会发生什么?发布您收到的错误。
  • updatableElements 未更新。可更新元素是带有上传图片文件的图片
  • fileUploadListener 是否被调用?是否有任何与浏览器相关的错误(检查开发者工具)。给我们更多的反馈,我们不能帮助你没有给出任何信息。提供更多XHTML代码、java代码。 that 是你的问题吗?

标签: jsf primefaces


【解决方案1】:

我已经解决了这个问题。我不知道为什么,但更改 #{cc.attrs.ajaxRenderCropDialog} 的值,更新工作。

之前::artistImageCropperDialog:imageCropperDialog

之后::artistImageCropperDialog:imageCropperForm

ImageCropperDialog xhtml 代码:

        <h:panelGroup layout="block" styleClass="links">
            <h:panelGroup id="imageCropperDialog" layout="block" styleClass="hidden">
                <h:form id="imageCropperForm">
                        <h:panelGrid>
                            <p:imageCropper id="cropperImage" value="#{cc.attrs.croppedImage}"
                                image="/upload/#{cc.attrs.imageTmp}"
                                initialCoords="#{cc.attrs.initialCoords}"
                                aspectRatio="1"
                                minSize="#{cc.attrs.minSize}"
                                required="true"
                                requiredMessage="Hay que seleccionar parte de la imagen"
                                />
                        </h:panelGrid>
                    <h:commandButton id="acceptButton" action="#{cc.attrs.acceptCropAction}" styleClass="hidden">
                        <f:ajax execute="@form" render="@form :messages :form:pictureHandler:updatableElements" onevent="onAcceptCropEvent"/>
                    </h:commandButton>

                    <h:commandButton id="cancelButton" action="#{cc.attrs.cancelCropAction}" styleClass="hidden">
                         <f:ajax execute="@this" render="@form :messages"/>
                    </h:commandButton>

                </h:form>
            </h:panelGroup>
        </h:panelGroup>
    </composite:implementation>

在其他xhtml中声明对话框:

<ui:define name="dialogs">
        <app:imageCropperDialog id="artistImageCropperDialog"
                        croppedImage="#{festivalArtistEditPageBean.croppedImage}"
                        imageTmp="#{festivalArtistEditPageBean.imageTemp}"
                        acceptCropAction="#{festivalArtistEditPageBean.cropImage()}"
                        cancelCropAction="#{festivalArtistEditPageBean.cancelCropImage()}"
                        minSize="#{festivalArtistEditPageBean.cropMinSize}"
                        initialCoords="#{festivalArtistEditPageBean.cropInitialCoords}"
                        >
        </app:imageCropperDialog>
    </ui:define>

【讨论】:

    猜你喜欢
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-25
    • 2017-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多