问题
I am using PrimeFaces 2.2. I am using p:fileuplaod, when fileUploads then using update i change the image on my page. Here it is.
<p:fileUpload id="countryFlag" widgetVar="uploader" description="Image"
update="Flag" allowTypes="*.jpg;*.png;*.gif;*.jpeg;" auto="true"
fileUploadListener="#{countryPages_Detail.imageUpload}">
<p:ajax oncomplete="test('Flag')" />
</p:fileUpload>
<p:graphicImage id="Flag" value="#{countryPages_Detail.imagePath}"
width="80" height="50" cache="false">
<f:event type="preRenderComponent" listener="#{countryPages_Detail.putImage}" />
</p:graphicImage>
What i want to do using script is that when upload completes, and using ajax when the image has been changed, then i want to check the image src attribute. Here is my test() function, it is not complete, but here it is
function test(imageId) {
var imgId = imageId;
var image = $("#saarcImagesTable tr").find("img[id='imageId']")
alert("Image change");
}
But I am getting error that
Parent not an instance of ClientBehaviorHolder: org.primefaces.component.fileupload.FileUpload@e39f71
Why am I am getting this error? What am I doing wrong?
Thanks
回答1:
The p:fileUpload
component does not implement the ClientBehaviorHolder interface as the message states and therefore is no component that can contain the ajax tag (see this post).
I am not familiar with the fileUpload component, but I've seen in the documentation of PF 3.2 that the p:fileUpload
has an oncomplete
attribute.
来源:https://stackoverflow.com/questions/10135689/how-to-use-pajax-oncomplete-event-on-pfileupload-getting-error-when-using