title: How to use p:ajax oncomplete event on p:fileUpload. Getting error when using
body: <p>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>
  
  <pre><code>&lt;p:fileUpload id="countryFlag" widgetVar="uploader" description="Image"
        update="Flag" allowTypes="*.jpg;*.png;*.gif;*.jpeg;" auto="true"
        fileUploadListener="#{countryPages_Detail.imageUpload}"&gt;
  
      &lt;p:ajax oncomplete="test('Flag')" /&gt;
  
  &lt;/p:fileUpload&gt;
  
  &lt;p:graphicImage id="Flag" value="#{countryPages_Detail.imagePath}"
        width="80" height="50" cache="false"&gt;
  
      &lt;f:event type="preRenderComponent" listener="#{countryPages_Detail.putImage}" /&gt;                                                 
  
  &lt;/p:graphicImage&gt;
  </code></pre>
  
  <p>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</p>
  
  <pre><code>function test(imageId) {
  
      var imgId = imageId;
      var image =  $("#saarcImagesTable tr").find("img[id='imageId']")
      alert("Image change");
  }
  </code></pre>
  
  <p>But I am getting error that </p>
  
  <blockquote>
    <p> Parent not an instance of ClientBehaviorHolder: org.primefaces.component.fileupload.FileUpload@e39f71</p>
  </blockquote>
  
  <p>Why am I am getting this error? What am I doing wrong?</p>
  
  <p>Thanks</p>