Foren

Primefaces file upload on live server

El Eng, geändert vor 6 Jahren.

Primefaces file upload on live server

New Member Beiträge: 22 Beitrittsdatum: 02.08.17 Neueste Beiträge
Hi,

I am try to upload a file through primefaces and store it in with DLAppService. This works perfectly fine, as long as I am doing it on my local machine.
However as soon as I deploy to our live server, I get Cannot read property 'getElementsByTagName' of null.
This error occurs in primefaces line 1140
var n = h.getElementsByTagName("partial-response")[0];
.

Are there any additional configurations necessary to allow file uploads through jsf/primefaces ?
Also I am using Liferay 7GA4.

Handler:
public void upload (FileUploadEvent event) throws IOException {
this.setPicture(event.getFile());}


JSF:
<p:fileupload id="fileUpload" fileUploadListener="#{uploadBean.upload}" mode="advanced" dragDropSupport="true" sizeLimit="100000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
thumbnail
Neil Griffin, geändert vor 6 Jahren.

RE: Primefaces file upload on live server

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
You might want to try clearing your browser cache when visiting the site hosted by the live server. It might be that you have an old primefaces.js cached. If that doesn't work, then please provide the text of the response (hopefully an XML document that starts with a <parital-response> element) here as a forum post attachment.
El Eng, geändert vor 6 Jahren.

RE: Primefaces file upload on live server

New Member Beiträge: 22 Beitrittsdatum: 02.08.17 Neueste Beiträge
clearing the cache didn't work.

Also I am not sure how to get the partial response with
h.getElementsByTagName("partial-response")[0];
being null.

I tried loggin the onerror(xhr, status, exception) callback but it seems like it is never called.

Thank you for your help.
thumbnail
Neil Griffin, geändert vor 6 Jahren.

RE: Primefaces file upload on live server

Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
You can examine the XHR response using Chrome. See attached screenshot which shows the contents of the partial-response after clicking on the "Submit" button of the General use-case for h:inputText in the JSF Showcase.
El Eng, geändert vor 6 Jahren.

RE: Primefaces file upload on live server

New Member Beiträge: 22 Beitrittsdatum: 02.08.17 Neueste Beiträge
Thanks for the example.
I tried it, but it just shows
This request has no response data available.


On my local server I get:
<partial-response id="_JSFIdeaBoard_WAR_JSFIdeaBoard_"><changes><extension ln="primefaces" type="args">{"parameterNamespace":"_JSFIdeaBoard_WAR_JSFIdeaBoard_"}</extension><update id="_JSFIdeaBoard_WAR_JSFIdeaBoard_:javax.faces.ViewState:0">9021189885547529217:-8947695983540338547</update></changes></partial-response>
El Eng, geändert vor 6 Jahren.

RE: Primefaces file upload on live server (Antwort)

New Member Beiträge: 22 Beitrittsdatum: 02.08.17 Neueste Beiträge
I figured it out. I was mistakenly using Liferay 7 GA3 on the live server.
After switching to GA4 everything works perfectly.
Sorry for the inconvenience.