当我上传文件时,我需要更新一些组件。它只在我第一次这样做时才有效。
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>
有什么想法吗?
答案 0 :(得分:0)
我已经解决了这个问题。我不知道为什么改变#{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>