简体   繁体   English

JSF 2.0组件

[英]JSF 2.0 Components

Does anyone know of any good resources for JSF 2.0 components? 有谁知道JSF 2.0组件的任何好资源? 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. 我正在尝试开发一个文件上传组件来自学JSF 2.0和Servlet 3.0,但我很难找到资源。 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. 我一直在关注Mojarra 2.0.2源码,但似乎很多东西仍在使用JSF 1.x概念。 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. 上周在Sun论坛上,有人发布了一个自定义JSF 2.0文件上传组件的示例,但是它是在Apache Commons FileUpload API上构建的,代码在这里有几个缺陷,但它可能是足够的信息开始。 Be careful though, some of those flaws are serious: JavaServer Faces - Creating JSF 2.0 File Upload Component 但要小心,其中一些缺陷是严重的: JavaServer Faces - 创建JSF 2.0文件上载组件

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. 巧合的是,我最近还在围绕JSF 2.0文件上传组件的想法,结合我的博客上新文章的新Servlet 3.0多部分支持。 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. 很难@FacesComponent创建JSF 2.0自定义组件( @FacesComponent )的最佳方式是什么,Google稍微透露一点,只有Jim Driscoll的这个博客有点用处。 Further it's nowhere explained in the Java EE 6 tutorial and even the JSF 2.0 specification tells nothing about it. 此外,它在Java EE 6教程中没有解释,甚至JSF 2.0规范也没有说明它。

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. 更新:我得到了它的工作,但有一个主要的缺点:我无法使用Servlet 3.0 @MultipartConfig注释来指定上传位置和最大文件大小。 This get activated only if set on a Servlet , not on a Filter . 仅当在Servlet上设置而不在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. 由于FacesServlet被声明为final并且在FacesServlet启动之前JSF没有提供让另一个Servlet处理请求的工具,我没有看到任何干净的方法来使用注释。 Normally the upload location is to be configured in the annotation, but this is easy workaroundable by using Part#getInputStream() instead of Part#write() . 通常,将在注释中配置上载位置,但通过使用Part#getInputStream()而不是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). 如果没有注释,最大文件大小将无法配置,因此您必须使用“无限大小上传”以及您只能在上传完成时进行验证(另一方面可能是优势) ,因为最终用户否则将面临丑陋的HTTP 500错误)。

Update 2: : here's the blog: http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html Hope this helps :) 更新2:这里是博客: http//balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html希望这有帮助:)

I would highly recommend taking a look into PrimeFaces : http://primefaces.org/ 我强烈建议您查看PrimeFaceshttp//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. 它是一个为JSF构建的组件套件(并且特别支持JSF 2.0),在开源许可下,使用YahooUI,并支持您的文件上传方案。

The standard JSF components do not include a file upload component. 标准JSF组件不包含文件上载组件。 This component is usually provided in in 3rd-party JSF component libraries such as myfaces, icefaces, etc... 此组件通常在第三方JSF组件库中提供,例如myfaces,icefaces等...

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. 目前我还不知道任何准备就绪的JSF 2.0组件库(除了规范标准),所以我不知道任何JSF 2.0准备好的文件上传组件。

我在这里有一些例子: http//mcatr.blogspot.com/search/label/JSF希望它有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM