Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileUpload not working on Liferay 6.2 when other JSF portlet exists on page #2025

Closed
lwojtysiak opened this issue Jan 19, 2017 · 13 comments
Closed

Comments

@lwojtysiak
Copy link

IMPORTANT

I have a problem with FileUpload component placed on webpage with twoi portlets.
First portlet is placed as runtime in Liferay theme, and the second one is "normal" portlet with file upload component.
The problem is that while trying to select file from system dialog and push "Select" - nothing happens. File is not showing in component and it is not possible to upload it.
In javascript I can see error "FileUpload is not defined".

When I debugging DOM in FF, I can see
Primefaces.widget array, where actually FileUpload is not available.

This situation worked at Primefaces 5.3 and not working on PF 6.0

As i think, the problem is with:

  • Liferay way of loading resources for runtime portlets
  • reloading core.js and components.js by PF (and clearing array PrimeFaces.widget)

in core.js I can see the line to clear Primefaces.widget array, and in components.js there is code which adds basic component to this array - but not FileUpload (and SimpleFileUpload, and as I remember one more).
The problem is that when Liferay loads resources for webpage, it places all resources in head (for example fileupload.js from second portlet) In this way - everything is ok, because core.js and components.js are placed "higher".
The problem is that when we have runtime portlet, it's resources are placed in at the end or JSF portlet.

Because of that we have such situation in result HTML:

  1. HEAD
  • load core.js
  • load components.js
  • load fileupload.js
  1. BODY:
  • first portlet
  • load core.js
  • load components.js
  • second component with fileupload.js

There is line:
if(window.PrimeFaces){window.PrimeFaces.debug("PrimeFaces already loaded, ignoring duplicate execution.");return
in core.js

but as I think - it's not working, and after loading core.js second time... it's clearing Primefaces.widget once again, and because fileupload.js not exists second time - it's "not loaded".

1) Environment

  • PrimeFaces version: 6.0
  • Does it work on the newest PrimeFaces version?
  • Application server + version: Liferay 6.2.1 + Faces Bridge 3.2.4ga5
  • Affected browsers: All browsers

2) Expected behavior

FileUpload component shows selected file (or error message if not correct file chosen) and give possibility to upload

3) Actual behavior

After selecting file in FileUpload component nothing happens

4) Steps to reproduce

Liferay web page with:

  1. JSF portlet added to theme with
    $theme.runtime("portlet_name");
  2. JSF portlet with FileUpload component
  3. Select file

5) Sample XHTML

<p:fileUpload id="fileId" update="@this,fileNamePanelId" auto="true" value="#{cc.attrs.fileUpload}" label="#{cc.attrs.fileUploadLabel}"
allowTypes="#{cc.attrs.allowTypes}" invalidFileMessage="#{cc.attrs.invalidFileMessage}"
fileUploadListener="#{cc.attrs.bean.handleFileUpload}" fileLimit="1" required="true" disabled="#{cc.attrs.disabled}" />

6) Sample bean

Not important

@tandraschko
Copy link
Member

Would you please try a trunk build? We fixed many of small bugs on the new dynamic resource loading feature.

@lwojtysiak
Copy link
Author

you mean PF 6.1-SNAPSHOT from branch master in github?
Should I download it from github and user from local repository - or "it's not so simple"? :)

@tandraschko
Copy link
Member

Just download the master from github and build it -> https://github.com/primefaces/primefaces/wiki/Building-From-Source

@lwojtysiak
Copy link
Author

Unfortunately - still the same:
"Widget not available: FileUpload"

(and: Widget not available: Layout)

@tandraschko
Copy link
Member

@stiemannkj1 Do you have time to check that issue? Seems to be related to dynamic resource loading. I thought we catched all the issues :/

@stiemannkj1
Copy link
Contributor

@lwojtysiak, you are using an old version of Liferay Faces. Please upgrade to our newest jars (you can use our archetype portlet to determine which dependencies and versions you need) and let us know if the issue persists.

@lwojtysiak
Copy link
Author

Sorry, but I cannot upgrade all libraries in my environment. I had some problems with Primefaces and I suppose, that upgrading Liferay Faces will have some more problems...

Anyway - with Primefaces 5.3 everything (in that case) worked. Primefaces.js was loaded twice (in head and in body -> as in 6.0), but probably Primefaces.widget wasn't cleared (there is line to clear it, but I think it wasn't called, because of check that Primefaces is already loaded). It seems like this check is not working on Primefaces 6.0 - nothing more changed in my code (and liferays also)

@stiemannkj1
Copy link
Contributor

@lwojtysiak, Liferay Faces 3.2.4-ga5 was released long before PrimeFaces 6.0 existed, so we never tested with PrimeFaces 6.0. Consequently using PrimeFaces 6.0 with Liferay Faces 3.2.4-ga5 is not supported (the same goes for 3.2.5-ga6).

If you want, you could upgrade your development environment to use the latest versions of Liferay Faces, see if the issue is still there, and report it. However, that bug would only be fixed in the latest Liferay Faces versions (in the new version scheme).

@lwojtysiak
Copy link
Author

In my opinion, problem is not with Liferay Faces and putting this script second time in HTML.
Because I can put this files in portlet manually.
The problem is, that scripts from core.js and components.js shouldn't run second time if already loaded. Specially if there is "Primefaces.widget = {}"

tandraschko added a commit that referenced this issue Jan 20, 2017
@tandraschko
Copy link
Member

likely fixed the core.js reloading. component.js were always reloaded, so i didn't change this behavior.

Please try.

@lwojtysiak
Copy link
Author

Looks better, because Primefaces.widget contains FileUpload.
But right now I have:
TypeError: this.jq.fileupload is not a function

@tandraschko
Copy link
Member

No idea, sry. If you can reproduce it with a simple maven/jetty application, i can check it. Otherwise please investigate by yourself or upgrade liferay.

@tandraschko
Copy link
Member

Will close it for now. If we can fix something, please comeback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants