Which components are better to use for uploading files in SWF 2.0 + JSF applications? Which are definetly work? Please share your experience
Thank in advance.
Which components are better to use for uploading files in SWF 2.0 + JSF applications? Which are definetly work? Please share your experience
Thank in advance.
I have used the myfaces tomahawk file upload component for years. The max file size is adjustable in web descriptor. I works very well and is easy to configure and use.
I have also used richfaces 3.2.x file upload - very nice. The richfaces file upload is only available in version 3.2.x (requires JSF 1.2 features). They do not have a file upload component in version 3.1.x (JSF 1.1).
I'm using tomahawk file upload too and it works but not the max file size. I don't know why? My config is:
Are u sure the max file size is working under SWF?Code:<filter> <filter-name>MyFacesExtensionsFilter</filter-name> <filter-class> org.apache.myfaces.webapp.filter.ExtensionsFilter </filter-class> <init-param> <param-name>uploadMaxFileSize</param-name> <param-value>7m</param-value> </init-param> <init-param> <param-name>uploadThresholdSize</param-name> <param-value>100k</param-value> </init-param> </filter>
Hi,
I'm using the richfaces file upload component. It works, but it always shows a message that saying that the upload was not sucefull, if you manage to ignore this message it will be usefull.
Pedro
Hi, Pedro, tanks for reply
I also use rich:fileUpload and get the same issue. It works, but error message appears.
Ok,
First, we need to config the upload component on web.xml, in this case I only set that a temp file must be created on the upload:
Then we add the component to the xhtml or jsp:Code:<filter> <display-name>RichFaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> <init-param> <param-name>createTempFiles</param-name> <param-value>true</param-value> </init-param> </filter>
In this case I set the FileUpload class as a service bean (@Service) and implemented a listerner method:Code:<rich:fileUpload listHeight="58" immediateUpload="true" fileUploadListener="#{fileUpload.listener}"/>
As I said the file is uploaded, I can save it on the JCR repository, but I had the error message on the component and the carType bean is not set, actually is set, but in the end of the flow carType.image is null (and I'm preety sure that after carType.setImage(uuid) a value is on the property).Code:public synchronized void listener(UploadEvent event) throws Exception { UploadItem item = event.getUploadItem(); String uuid = jcrService.createFile(item.getFile(), item.getContentType()); if (context instanceof CarType) { CarType carType = (CarType) context; carType.setImage(uuid); } }
No need to add further configuration on the flow.
I hope this will help you,
Pedro Casagrande
Thanks. In fact, it was working (my fault!). Using a model bean instead of a Service stores the file correctly.
Regards,
The transfer error still shows (I'll hide it with CSS prolly) but the item is available at the end of the flow. So good enough for me