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

流过昼夜 提交于 2019-12-25 10:02:40

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!