Reputation:
I am posting this Question after alot of Googling and alot of experiments with the af:image component .
my case is the following :
i have an af:link that is opening a af:popup from the backing bean like the following :
<af:link text="Link" id="l3"
actionListener="#{myBean.myActionListener}">
<f:attribute name="personId" value="#{row.PersonId}"/>
<f:attribute name="fullName" value="#{row.FullName}"/>
</af:link>
and myActionListener method is like the following :
public void myActionListener(ActionEvent actionEvent) {
if (actionEvent.getComponent().getAttributes().get("personId") != null) {
Long personId = (Long) actionEvent.getComponent().getAttributes().get("personId");
String fullName = (String)actionEvent.getComponent().getAttributes().get("fullName");
// puting the attributes in the page Flow Scope
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("currentPersonId", currentPersonId);
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("currentFullName", currentFullName);
String imageUrl = "/myImageServlet?personId="+personId ;
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("imageUrl", imageUrl);
// check if the image is stored in the file system
String fileLocation = "C:\\pics\\" ;
File imageFile = new File(fileLocation + personId);
if(imageFile.exists()){
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("personImageExist", true);
}else {
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("personImageExist", false);
}
//show the popup here
RichPopup.PopupHints hints = new RichPopup.PopupHints();
this.getImagePopupTab2().show(hints);
}
}
then comes my popup with the af:image like the following :
<af:popup childCreation="immediate" autoCancel="disabled" id="imagePopupTab2"
binding="#{myBean.imagePopupTab2}" contentDelivery="lazyUncached">
<af:dialog id="d123456" closeIconVisible="false">
<af:panelGroupLayout id="pgl899" layout="vertical">
<af:panelGroupLayout id="pgl1110" layout="horizontal">
<af:spacer width="20" height="10" id="s34"/>
<af:image source="#{pageFlowScope.imageUrl}"
id="i222" rendered="#{pageFlowScope.personImageExist}"
/>
</af:panelGroupLayout>
</af:panelGroupLayout>
</af:dialog>
</af:popup>
the following works well , my problem comes when i try to update the image file in the file system , then call the popup again , the old image is still cached there , and it wont refresh .
ive tried the following solutions and it didnt work :
1- add A partial trigger for the af:image to refresh after the update.
2- add a partial trigger to af:image parent layout to refresh .
3- i tried to set the source attribute to the af:image from inside the backing bean .
4- i also tried h:graphicImage and tr:image same thing .
the problem is , the af:image is not calling the source Servlet again , and i dont know why .
Upvotes: 0
Views: 1177
Reputation: 11
Is the servlet URL the same before and after refresh? If so, try adding a param to the URL so that its different after refresh.
For example:
/imageservlet?id=302201&refreshTrigger=1
It is spoken about briefly in "Important points" of this blog post.
Upvotes: 1
Reputation: 1657
Try to expose af:image's binding into the backing bean:
<af:image binding="#{myBean.imageComp" source="#{pageFlowScope.imageUrl}"
id="i222" rendered="#{pageFlowScope.personImageExist}"
/>
In myActionListener method, do a programatic PPR:
AdfFacesContext.getCurrentInstance().addPartialTarget(getImageComp());
Upvotes: 0