I'm doing file upload and have implemented it the way it is suggested here:
http://wiki.apache.org/myfaces/Setup_For_File_Uploads
On the view I have this code to do upload:
| <t:inputFileUpload storage="file" immediate="true">
| <f:valueChangeListener type="com.myorg.foo.UploadListener" />
| </t:inputFileUpload>
|
|
| The listener that processes the upload is something like :
|
| public class UploadListener implements ValueChangeListener {
| public void processValueChange(ValueChangeEvent event) throws
AbortProcessingException {
|
|
| // Upload and do something with uploadedFile
| }
| }
|
With the listener being a POJO, everything works OK.
Now I have changed to code of the UploadListener to do some logging and save the file to a
location depending on the username. So to me it sounds like making it an EJB3 component is
the best approach:
| @Stateless
| @Name("uploadListener")
| public class UploadListener implements ValueChangeListener {
| @Logger
| private Log log;
|
| @PersistenceContext
| private EntityManager em;
|
| @In User user;
|
| public void processValueChange(ValueChangeEvent event) throws
AbortProcessingException {
|
| if (log == null) System.out.println("Log is null !!" );
| if (em == null) System.out.println("EntityManager is null
!!" );
| if (user == null) System.out.println("User is null !!" );
|
| // Upload and do something with uploadedFile
| }
| }
|
But here where I have a surprise. I'm getting:
Error EntityManager is null !!
User is null !!
Log is null !!
I have tried to make it implement a local empty interface as well, but still no success.
Am I doing the right thing ? Any idea ?
Thx
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4027505#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...