Skip to main content

file upload with mojarra or MyFaces, or Richfaces

5 replies [Last post]
szhb69
Offline
Joined: 2009-07-15
Points: 0

My application with JSF2 requires and uses a file upload facility. As not directly avilable, I adapted the version of balusC, based on com.sun.faces.renderkit, which runs almost fine on Glassfish/Mojarra.
But the application must run on WebSphere, Weblogic, Jboss AS7 and maybe even other servers too! That is where the problems start. "com.sun.faces.renderkit" is not supported directly on those servers.
Does anybody have experience with MyFaces/Trinidad, or Richfaces on Glassfish?
What is the outcome?
Has anybody used "com.sun.faces.renderkit" on one of the other servers?
Any hint is welcome.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
oversteer
Offline
Joined: 2011-03-28
Points: 0

I've certainly found the tomahawk t:inputFileUpload the only solution I can get to work
when using container security, I've never been able to get the primefaces or richfaces
file uploads to work in this scenario. It must be used in a form with h:form enctype="multipart/form-data" and I found it best to only do the file upload inside this
form. I've a vague recollection of having other input components inside the form along
with the file upload and experiencing performance problems.

It's also worth noting that t:inputFileUpload is a strictly non-ajax solution. I tried
to submit the form using the ajaxified a4j:commandButton and it wouldn't work.

JSF 2.2 comes with a file upload component thankfully.

<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>10m</param-value>
        </init-param>
        <init-param>
            <param-name>uploadThresholdSize</param-name>
            <param-value>100k</param-value>
        </init-param>
</filter>
tkanters
Offline
Joined: 2011-08-24
Points: 0

A good suggestion is the tomahawk file upload. You only need to register a filter, add the dependency and make sure any form with a file field has the correct encoding. But that is all described in the docs. You can only use the file upload ability in regular requests (so no AJAX requests).

szhb69
Offline
Joined: 2009-07-15
Points: 0

Ok, thanks, good hint.
Yes, I've seen tomahawk until now, rather as an extension for jsf1.2 not for jsf2. I was wrong and have corrected this meaning.
But, why do a halve step only? Why should I prefer tomahawk about trinidad?
Is it because I can continue to stick with Mojarra?
But, going to WebSphere, Mojarra isn't a good choice. MyFaces has a better support. So requiring MyFaces core for WebSphere 8.x anyway, would trinidad not be the better choice, though I'll use the file upload only?

tkanters
Offline
Joined: 2011-08-24
Points: 0

It really is a question about your requirements. Personally I like MyFaces over Mojarra. I haven't used either of them in combination with trinidad so I can't say much about that.

Trinidad offers you a lot more than tomahawk and you need to think about wether you need/want them. If like you say, you will only use the fileupload,.. then I would just use thomahawk. I is the most light weight and easy solution.

szhb69
Offline
Joined: 2009-07-15
Points: 0

Thanks for your hint. Until now, I was just using Glassfish/Mojarra, because it was here and it was easy. By crossing the borders to other AS, things change. So, I just started claiming terrain. As so many disparate implementations of JSF exist, it's harder, than it looks at first view. Beside WebSphere I'm fighting jboss AS7.1 to start with Myfaces and Tomahawk! As 7 doesn't start my application, but neither the tomahawk-examples. The latter runs with tomcat, after rebuild and compilation, like the example.war, but crashes with exactly the same initialization error as my application! Happy manifold world!