0

I am using Primefaces 12.0.0 , Jakarta ee 9, jsf 3.0 and Glassfish 6.2.5 . After I have added rewrite-config-prettyfaces-6.0.0.Alpha1 and I have added url rewiting in pretty-config.xml file, fileupload stop working.
According to this link How to use PrimeFaces p:fileUpload? Listener method is never invoked or UploadedFile is null / throws an error / not usable , I did not add PrimeFaces file upload filter and primefaces.UPLOADER context parameter in web.xml.

index.xhtml:

<h:form>
        
        <p:growl id="messages" showDetail="true"/>

        <h5>Basic</h5>
        <p:fileUpload listener="#{testBean.handleFileUpload}" mode="advanced" dragDropSupport="true" 
                      update="messages"  allowTypes="/(\.|\/)(gif|jpe?g|png)$/" >    
        </p:fileUpload>        
        
</h:form>

handleFileUpload method:

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

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="5.0" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://jakarta.ee/xml/ns/jakartaee">
    <context-param>
        <param-name>jakarta.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>    
   
</web-app>

pretty-config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces  
                      http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd"> 

    <url-mapping id="home">
        <pattern value="/index"></pattern>
        <view-id>/faces/index.xhtml</view-id>        
    </url-mapping>

</pretty-config>

Any ideas about what would be wrong?

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
shamin
  • 11
  • 2

0 Answers0