0 Replies Latest reply on Jun 6, 2010 2:26 PM by Turion Danae

    s:fileUpload among other input fields in one form

    Turion Danae Newbie

      Hello guys,

      I'm new to Seam and the whole Java EE thing and - coming from PHP - I'm frequently wondering about how to get simple things to work. I managed to implement a simple file upload using a multipart form containing one s:fileUpload tag. I've got a data bean called Attachment.java which holds the file's data and I've got a session bean which adds the file to my database. Just a simple test implementation, but it works.

      Now, how can I put multiple fileUpload fields together with some other normal input fields (like inputText) on the same page? On that page a user is supposed to send in his application. All the normal input fields refer to the properties of a data bean called Application.java, i.e. application.firstName, application.lastName, etc. Each application also consists of some file attachments annotated whith @OneToOne, i.e. application.someFile with someFile being of type Attachment. So if I click Send application, i need those uploaded files (precisely: their primary keys) to be stored in the corresponding application properties.

      I've got a notion that there will be at least two problems:
      1. A file upload needs a multipart/form-data form. Is it possible to put normal input fields inside of such a form?
      2. Until now I used custom converters when storing a reference to object A inside another object B, for example when using SelectOneMenus containing custom objects. Is something like this applicable on uploaded files? Or would it be better to put some file variables in my session bean, refer to those variables from my fileUpload fields and then manually persist the files and add there IDs to the application object before persisting the application itself?

      As this seems to be a quite normal use case, I'd bet some people already implemented something like this. I could relly need some help :o) Thanks in advance.