Forums de discussion

Primefaces file upload on live server

El Eng, modifié il y a 6 années.

Primefaces file upload on live server

New Member Publications: 22 Date d'inscription: 02/08/17 Publications récentes
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, modifié il y a 6 années.

RE: Primefaces file upload on live server

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
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, modifié il y a 6 années.

RE: Primefaces file upload on live server

New Member Publications: 22 Date d'inscription: 02/08/17 Publications récentes
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, modifié il y a 6 années.

RE: Primefaces file upload on live server

Liferay Legend Publications: 2655 Date d'inscription: 27/07/05 Publications récentes
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, modifié il y a 6 années.

RE: Primefaces file upload on live server

New Member Publications: 22 Date d'inscription: 02/08/17 Publications récentes
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, modifié il y a 6 années.

RE: Primefaces file upload on live server (Réponse)

New Member Publications: 22 Date d'inscription: 02/08/17 Publications récentes
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.