Dynamic view-id and FileUpload (simple mode) doesn't work

Splash Forums PrettyFaces Users Dynamic view-id and FileUpload (simple mode) doesn't work

This topic contains 4 replies, has 3 voices, and was last updated by  Christian Kaltepoth 4 years, 5 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #19106

    Hello guys,

    I have a problem that I don’t know how to handle it, here’s the situation :

    I have a mapping like this :

    <url-mapping id="channel">
    <pattern value="/#{/[A-Za-z0-9-_]+/?/ bean.slugl}"/>
    <view-id value="#{bean.defineView}"/>
    <action onPostback="false">#{bean.load}</action>
    </url-mapping>

    and every time that I try to send a file to server I got this error :

    Caused by: java.lang.NullPointerException
    at org.primefaces.component.fileupload.FileUploadRenderer.decodeSimple(FileUploadRenderer.java:55)
    at org.primefaces.component.fileupload.FileUploadRenderer.decode(FileUploadRenderer.java:46)
    at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:787)
    at javax.faces.component.UIInput.decode(UIInput.java:757)
    at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1181)
    at javax.faces.component.UIInput.processDecodes(UIInput.java:662)
    at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
    at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
    at javax.faces.component.UIForm.processDecodes(UIForm.java:225)
    at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
    at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1176)
    at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:933)
    at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

    this happen because the file is no longer on my request since that the FileUpload filter is called twice, one time when

    pretty-faces call my method #{bean.defineView} and the second one when the view is called.

    my web.xml looks like this :

    <filter>
    <filter-name>Pretty Filter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
    </filter>
    <filter-mapping><br />
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</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>2097152</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    <filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    </filter-mapping>

    there’s any way to get fileUpload simple mode working with dynamic view-id ?

    Thanks in advanced!

    #23226

    Hi, I think you are missing <dispatcher>ASYNC</dispatcher> and async support in your filter mappings — http://ocpsoft.org/prettyfaces/#section-8

    #23227

    @lincoln: Yeah, I think you are right. I remember that this was required for the Primefaces upload component. I think there is a post regarding this somewhere on our forums.

    @vinioliveira: Beside the async issue I also think that it is not a got idea to configure the Primefaces filter for both FORWARD and REQUEST. This is the cause why the filter gets executed twice. You should choose one of the two dispatcher types. I’m not sure which one will work. You should try both. You may also need to move the Primefaces filter in front of the PrettyFilter if you set dispatch to REQUEST.

    #23228

    @christian it’s worked ! I tested both and I left the dispatch REQUEST and move to top the fileupload filter.

    Also I didn’t need to set ASYNC dispatch on prettyfaces filter.

    Thanks for the help! I really appreciate.

    #23229

    You’re welcome! :)

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Comments are closed.