How to use p: ajax oncomplete event on p: fileUpload. Getting error while using

I am using PrimeFaces 2.2. I am using p: fileuplaod when fileUploads, using refresh, 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 with a script is that on load it finishes and using ajax when the image has been resized then I want to check the src attribute of the image. 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 the error

Parent is not an instance of ClientBehaviorHolder: org.primefaces.component.fileupload.FileUpload@e39f71

Why am I getting this error? What am I doing wrong?

thank

0


source to share


1 answer


The component p:fileUpload

does not implement the ClientBehaviorHolder interface because the message state and therefore is not a component that can contain an ajax tag (see this post ).



I'm not familiar with the fileUpload component, but I've seen in the PF 3.2 documentation that it p:fileUpload

has an attribute oncomplete

.

+2


source







All Articles