Page 1 of 1

Bug of component p:fileUpload

Posted: 10 Jan 2017, 16:38
by ubicamovil
I have 2 problems with the p component: fileUpload

1: when trying the automatic load does not execute anything, and the console does not show me errors, for this and try with the different examples of showCase and none works, only happens to me with this theme.

2: Your official page of the subject supposedly at the end of loading the file tries to update the elements but hidden other components like (TopBar, LeftMenu, Navigation menu).

If someone can tell me if the same happens to them or is just my particular case.

Re: Bug of component p:fileUpload

Posted: 11 Jan 2017, 03:19
by Melloware
Is this related to the Atlantis layout or a PrimeFaces issue you are having in general? If you take Atlantis out of the equation with just bare bones PrimeFaces does your issue still happen?

Re: Bug of component p:fileUpload

Posted: 11 Jan 2017, 15:11
by ubicamovil
I am using other themes (Sentinel, Adamantium) in none caused me problems with the component, so I think it is the Atlantis Layout.

In the browser console sends me the following warnning "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience." When running the component.

I also mentioned that I am using PrettyFaces and this can cause problems but I still can not solve it.

I leave reference to my code web.xml

<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ASYNC</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>


<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
<init-param>
<param-name>thresholdSize</param-name>
<param-value>12051200</param-value>
</init-param>
<init-param>
<param-name>uploadDirectory</param-name>
<param-value>/tmp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>



My context.xml

<Context allowCasualMultipartParsing="true" antiJARLocking="true">
<Loader delegate="true"/>
</Context>

Re: Bug of component p:fileUpload

Posted: 12 Jan 2017, 09:16
by mert.sincan
Interesting! I tested this issue on Atlantis Layout and Theme, but I didn't see a problem. Can you please attach a sample page for us to replicate? What PF-version are you using? Also, can you please try this issue using our sample project? (We have file.xhtml page that have FileUpload demo in it)

Re: Bug of component p:fileUpload

Posted: 12 Jan 2017, 15:18
by ubicamovil
I solved the problem with some complications, the problem was in the filter-mapping of prettyFaces as of FileUpload I leave my configuration and my code and I explain the complications.

<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>

<filter>
<filter-name>primeFacesFileUploadFilter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
<init-param>
<param-name>thresholdSize</param-name>
<param-value>12051200</param-value>
</init-param>
<init-param>
<param-name>uploadDirectory</param-name>
<param-value>/tmp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>primeFacesFileUploadFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>

<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>commons</param-value>
</context-param>

<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>


Take into account the order of <dispatcher> of springSecurityFilterChain I think that was the problem, if you could explain a little more if this affects my original problem.


<h:form prependId="false" enctype="multipart/form-data">
<p:fileUpload fileLimit="1"
required="true"
mode="advanced"
update="messages"
auto="true"
sizeLimit="1000000"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/"
fileUploadListener="#{viewExampleMB.handleFileUpload}"
requiredMessage="invalidMessage"
validatorMessage="invalidMessage"
invalidFileMessage="invalidMessage"
invalidSizeMessage="invalidMessage"
converterMessage="invalidMessage"
fileLimitMessage="invalidMessage"/>
<p:growl id="messages" autoUpdate="true" showDetail="true" showSummary="true"/>
</h:form>

public void handleFileUpload(FileUploadEvent event) {
FacesMessage message = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
FacesContext.getCurrentInstance().addMessage(null, message);
}


pom.xml
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.0.0-rc1</version>
</dependency>


pretty-config.xml

<url-mapping id="file-example">
<pattern value="/FileExample" />
<view-id value="/content/example/file.xhtml" />
</url-mapping>


I'm using Jboss7.1.1 and PF 6.0

The problems that I present now is that when you pass the restrictions (allowTypes, sizeLimit, etc.) correctly enters the fileUploadListener and executes everything correct, but when you do not pass any of these restrictions does nothing does not update the growl and shows no errors.
Any ideas to this problem?
Thanks for the help.

Re: Bug of component p:fileUpload

Posted: 12 Jan 2017, 15:30
by mert.sincan
Glad to hear, thanks for the update! Maybe you can try it without prettyFaces.

Re: Bug of component p:fileUpload

Posted: 12 Jan 2017, 15:46
by ubicamovil
I need to use prettyFaces :/

Re: Bug of component p:fileUpload

Posted: 22 Feb 2017, 12:17
by mert.sincan
Unfortunately, I'm not a prettyFaces expert. Maybe, you can ask this question to prettyFaces developers.