Results 1 to 10 of 10

Thread: SWF + JSF file upload

  1. #1
    Join Date
    Feb 2008
    Location
    Kharkov, Ukraine
    Posts
    64

    Default SWF + JSF file upload

    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.

  2. #2
    Join Date
    Feb 2005
    Posts
    7

    Default

    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).

  3. #3

    Default

    Quote Originally Posted by lbbisho View Post
    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'm using tomahawk file upload too and it works but not the max file size. I don't know why? My config is:
    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>
    Are u sure the max file size is working under SWF?

  4. #4
    Join Date
    Feb 2008
    Posts
    29

    Default

    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

  5. #5
    Join Date
    Feb 2008
    Location
    Kharkov, Ukraine
    Posts
    64

    Default

    Hi, Pedro, tanks for reply

    I also use rich:fileUpload and get the same issue. It works, but error message appears.

  6. #6
    Join Date
    Dec 2005
    Posts
    148

    Default

    Quote Originally Posted by pccampos View Post
    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.
    I'm having troubles to get it to work. Could you post the flow or other relevant parts of the config?

    Regards,

  7. #7
    Join Date
    Feb 2008
    Posts
    29

    Default

    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:

    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>
    Then we add the component to the xhtml or jsp:

    Code:
    <rich:fileUpload listHeight="58" immediateUpload="true" fileUploadListener="#{fileUpload.listener}"/>
    In this case I set the FileUpload class as a service bean (@Service) and implemented a listerner method:

    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);
    		}
    	}
    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).

    No need to add further configuration on the flow.


    I hope this will help you,
    Pedro Casagrande

  8. #8
    Join Date
    Dec 2005
    Posts
    148

    Default

    Thanks. In fact, it was working (my fault!). Using a model bean instead of a Service stores the file correctly.

    Regards,

  9. #9
    Join Date
    Feb 2008
    Posts
    29

    Default

    Have you got it working? I've moved the listener method to my @Entity bean but I still got the "Transfer error occuried" message.

    Quote Originally Posted by xmaniac View Post
    Thanks. In fact, it was working (my fault!). Using a model bean instead of a Service stores the file correctly.

    Regards,

  10. #10
    Join Date
    Dec 2005
    Posts
    148

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •