0

So i have seen several questions about similar issues, anyway i cannot fix my problem.

I want to use primefaces' fileUpload functionality to upload multiple files. So i have this in my xhtml. I built it based on the instructions here: How to use PrimeFaces p:fileUpload? Listener method is never invoked or UploadedFile is null

xhtml:

<h:form enctype="multipart/form-data">

        <p:fileUpload fileUploadListener="#{controller.upload}" multiple="true"></p:fileUpload>
</h:form>

Note:

  • upload is within a h:form tag
  • enctype is set to multipart/form-data
  • I use "advanced" mode, and the <h:head> tag exists.

Configuration:

  • I use JSF2.2 and Primefaces 5.2, therefore i did not add additional configuration, as suggested in the post

My Bean:

@ManagedBean
@RequestScoped
public class controller implements Serializable {


 public void upload(FileUploadEvent event) throws IOException{
//Do something
}

Note:

  • I did it as suggested in the post for ajax-uploads.

Troubleshooting:

  • as i do not use the PrimeFaces file upload filter, suggestion 1 and 2 do not apply
  • i do not have a nested h:form
  • Checking traffic in browser: A Post request is being performed and i get Ok 200.

Further, the post states that the Request can only be parsed once (in relation to filter chain ordering). I have 2 (additional) active filter chains, spring security and pretty faces. Can one of those be the problem here?

Update: PrettyFaces seems, indeed, to be the cause of the problem. When disabling it, everything works.

Community
  • 1
  • 1
Heady
  • 935
  • 3
  • 10
  • 23
  • also combining `@ManagedBean @Component` on the same bean is not right iirc\ – Kukeltje Apr 02 '16 at 13:12
  • @Kukeltje: why would that make a difference? – Heady Apr 02 '16 at 20:56
  • Duplicate explains that filter is unnecessary with 5.x on JSF 2.2. And even when you use it, special considerations have to be taken into account when PrettyFaces is used. Nothing of all is visible in the information provided so far. As to Kukeltje's remark: http://stackoverflow.com/q/18387993 – BalusC Apr 02 '16 at 21:00
  • @BalusC thank you for your answer. However, i have also tried it without putting any pf-upload-filter in my web-xml, as the duplicate explained. It didnt change anything. Also removing the Spring annotation did not change anything, but thank you for the link,. – Heady Apr 02 '16 at 21:07
  • I suggest to start from scratch and carefully follow the instructions in the duplicate. You might have added/configured some random stuff which shouldn't have been necessary or were done incorrectly. When you still fails feel free to reframe the question based on the instructions in the duplicate. – BalusC Apr 02 '16 at 21:13
  • @BalusC: i edited my question, refering to every point of your linked answer. – Heady Apr 02 '16 at 21:25
  • Is the `FileUploadRenderer#decode()` method invoked? Does all the stuff start to work when you remove Spring Security or PrettyFaces? – BalusC Apr 03 '16 at 08:50
  • @BalusC: It works when disabling PrettyFaces – Heady Apr 03 '16 at 10:56

0 Answers0