mediaOutput only renders once?
arnieaustin Oct 22, 2015 10:24 PMConsider the markup below. The photo is stored as a blob. Using the imageLoader class from the RF photo library demo as a template, I simplified the code to output the bytes to the browser and the photo appears if the field is not null. The command link to empty the field also works at the DB level and the place holder graphic appears instead of the media output.
So the outputPanel is rendering as expected. But the mediaOutput is being invoked only when the page is initially rendered. I know this due to logging in the imageLoader class (called only once). If I pick a different photo, the mediaOutput appears, the place holder vanishes, but it is the original photo, not the new one.
I would have thought render="photoPerson" on one of the two (fileUpload or the uploadcomplete event) below would have forced it to regenerate, but alas no.
Putting imageLoader into the Conversation scope from Request didn't help either.
How does one get it to regenerate the graphic? Or is it something else? Like the URI of the photo resource not being updated in the browser resulting in the updated graphic not being downloaded?
<rich:panel style="vertical-align:top;">
<f:facet name="header"><h:outputFormat value="#{messages.getString('infoPersonEdit.name.label.photoFacet')}" /></f:facet>
<a4j:outputPanel id="panelInfoPersonPhoto" ajaxRendered="true" >
<h:panelGrid columns="1" columnClasses="table-column-center" >
<a4j:mediaOutput id="photoPerson" element="img" createContent="#{imageLoader.paintImage}"
value="#{infoPersonDTOCDI.id}" style="width:200px;height:200px;"
rendered="#{not empty infoPersonDTOCDI.photo}"
title="#{infoPersonDTOCDI.nameFirst} #{infoPersonDTOCDI.nameLast}" />
<h:graphicImage library="images" name="man-icon.gif"
rendered="#{empty infoPersonDTOCDI.photo}" style="width:200px;height:200px;"
title="#{messages.getString('infoPersonEdit.name.label.noPhotoTitle')}" />
<a4j:commandLink value="#{messages.getString('infoPersonEdit.name.label.clearPhoto')}"
rendered="#{!empty infoPersonDTOCDI.photo}" execute="@this"
render="panelInfoPersonPhoto"
status="statusInProgress"
actionListener="#{infoPersonEdit.clearPhotoListener}"
/>
<rich:fileUpload id="uploadPhoto" fileUploadListener="#{infoPersonEdit.photoUploadListener}"
immediateUpload="true" acceptedTypes=".jpg, .gif, .png"
maxFilesQuantity="1" maxFileSize="500000"
listHeight="0" status="statusInProgress" execute="@this" render="panelInfoPersonPhoto"
rendered="#{not empty infoPersonDTOCDI.id and !infoPersonDTOCDI.inactive and !infoPersonDTOEdit.readOnly}"
ontyperejected="alert('#{messages.getString('infoPersonEdit.name.label.invalidPhoto')}');"
>
<a4j:ajax event="uploadcomplete" execute="@this" render="panelInfoPersonPhoto" />
</rich:fileUpload>
</h:panelGrid>
</a4j:outputPanel>
</rich:panel>