开发者

JSF 2.0 Components

开发者 https://www.devze.com 2022-12-15 07:28 出处:网络
Does anyone know开发者_如何学C of any good resources for JSF 2.0 components? I\'m trying to develop a file upload component to teach myself JSF 2.0 and Servlet 3.0 but I\'m having a hard time finding

Does anyone know开发者_如何学C of any good resources for JSF 2.0 components? I'm trying to develop a file upload component to teach myself JSF 2.0 and Servlet 3.0 but I'm having a hard time finding resources. I've been looking at the Mojarra 2.0.2 source but it seems like a lot of their stuff is still using JSF 1.x concepts. Any insight is appreciated.


Last week at the Sun forum someone has posted an example of a custom JSF 2.0 file upload component, but it is built up on Apache Commons FileUpload API and the code has here and there several flaws, but it may be enough information to start with. Be careful though, some of those flaws are serious: JavaServer Faces - Creating JSF 2.0 File Upload Component

By a coincidence, I was lately also playing with the idea around a JSF 2.0 file upload component in combination with the new Servlet 3.0 multipart support for a new article at my blog. It's only hard to figure what's the best way to create a JSF 2.0 custom component (a @FacesComponent), Google reveals a little, only this blog of Jim Driscoll is somewhat useful. Further it's nowhere explained in the Java EE 6 tutorial and even the JSF 2.0 specification tells nothing about it.

Update: I got it to work, but there is one major disadvantage: I can't make use of the Servlet 3.0 @MultipartConfig annotation to specify the upload location and the max file size. This get activated only if set on a Servlet, not on a Filter. As the FacesServlet is declared final and the JSF provides no facility to have another Servlet to process the request before the FacesServlet kicks in, I don't see any clean ways to make use of the annotation. Normally the upload location is to be configured in the annotation, but this is easy workaroundable by using Part#getInputStream() instead of Part#write(). The max file size is in no way configureable without the annotation, so you'll have to live with "unlimited size uploads" and the fact that you can only validate it when the upload is complete (which may on the other hand be an advantage, because the enduser would otherwise face an ugly HTTP 500 error).

Update 2:: here's the blog: http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html Hope this helps :)


I would highly recommend taking a look into PrimeFaces: http://primefaces.org/

It is a component suite built for JSF (and specifically supports JSF 2.0) under open-source license, uses YahooUI under the covers, and supports your file upload scenario as well.


The standard JSF components do not include a file upload component. This component is usually provided in in 3rd-party JSF component libraries such as myfaces, icefaces, etc...

At the moment I don't know of any JSF 2.0 component libraries that are ready yet (other than the spec standard) so I'm unaware of any file upload components that are JSF 2.0 ready.


I have some examples here : http://mcatr.blogspot.com/search/label/JSF hope it helps

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号