Board index Premium Layouts and Themes Atlantis Bug of component p:fileUpload

Bug of component p:fileUpload


Post 10 Jan 2017, 16:38

Posts: 4
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.


Posts: 103
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?
PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces 6.0 / PF Extensions 6.0.0


Posts: 4
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>


Posts: 1929
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)


Posts: 4
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.


Posts: 1929
Glad to hear, thanks for the update! Maybe you can try it without prettyFaces.


Posts: 4
I need to use prettyFaces :/


Return to Atlantis