昨天我看了一个关于Java Server Faces 2.0的演示,它看起来确实令人印象深刻,尽管我现在是一个快乐的ASP。asp.net MVC / jQuery开发。我最喜欢JSF的地方是它有大量支持ajax的UI组件,这使得开发比使用ASP要快得多。NET MVC,特别是在ajax较多的站点上。集成测试看起来也很不错。
由于这个演示只强调了JSF的优点,所以我也想听听其他方面的情况。
所以我的问题是:
Java Server Faces 2.0的主要缺点是什么?
什么会使JSF开发人员考虑使用ASP。NET MVC而不是JSF?
I'm not a Java Server Faces expert at all. But IMHO the main disadvantage is that it's server side. I'm tired of learning and using server side web presentation layer frameworks like ASP.NET Web Forms, ASP.NET MVC, Java Server Faces, Struts, php frameworks and ruby on rails frameworks. I said goodbye to all of them, and I said hello to Angularjs and TypeScript. My presentation layer runs on the browser. I doesn't matter if it is served by Windows IIS running php or ASP.NET, or if it is served by an Apache web server running on Linux. I just need to learn just one framework that works everywhere.
这只是我的个人意见。
对我来说,JSF 2.0最大的缺点不仅是JSF的学习曲线,而且是为了让它做有用的工作而必须使用的组件库。想想你要真正精通需要处理的数量惊人的规范和标准:
HTML in the various incarnations. Don't pretend you don't need to know it.
HTTP -- when you can't figure out what is going on you have to open Firebug and see. For that you need to know this.
CSS -- Like it or not. It isn't so bad really and there are some nice tools out there at least.
XML -- JSF will probably the first place you use namespaces to this degree.
Servlet Specification. Sooner or later you will get into calling methods in this package. Aside from that you have to know how your Facelets gets turned into XHTML or whatever.
JSP (mostly so you know why you don't need it in JSF)
JSTL (again, mostly to cope with legacy framework)
Expression Language (EL) in its various forms.
ECMAScript, JavaScript, or whatever else you want to call it.
JSON -- you should know this even if you don't use it.
AJAX. I would say JSF 2.0 does a decent job of hiding this from you but you still need to know what is going on.
The DOM. And how a browser uses it. See ECMAScript.
DOM Events -- a topic all by itself.
Java Persistence Architecture (JPA) that is if you want your app to have any back end data base.
Java itself.
JSEE while you are at it.
The Context Dependency Injection specification (CDI) and how it clashes with and is used with JSF 2.0
JQuery -- I would like to see you get along without it.
现在,一旦你完成了这些,你就可以继续使用专有规范,即你将在此过程中获得的组件库和提供者库:
PrimeFaces(我选择的组件库)
RichFaces
MyFaces
ICEFaces
EclipseLink(我的JPA提供者)
Hibernate
焊接
别忘了容器!所有这些配置文件:
GlassFish(2,3等)
JBoss
Tomcat
那么——这让事情变得简单了吗?当然,JSF 2.0很“简单”,只要你想做的只是最基本的web页面和最简单的交互。
简单地说,JSF 2.0是当今软件界所存在的最复杂和最麻烦的技术大杂烩。我想不出还有什么更好的方法。
评论我过去几个月的Primefaces/JSF体验:
如果你可以使用“现成的”组件,我想这并不可怕。
然而,当你走到外面并需要定制ui时,它就不能很好地发挥作用。-例如,我们需要在项目中使用Twitter的bootstrap。(不是primefaces bootstrap)。
现在我们的页面工作如下:
页面加载。
用户与具有ajax功能的Primefaces交互
Bootstrap的javascript绑定中断
我们运行额外的javascript来重新绑定所有内容
JSF避免编写javascript的承诺变成了编写比不使用Primefaces时更多的javascript——而javascript是用来修复Primefaces破坏的。
这是一个时间消耗器——除非你再次使用现成的东西。当不得不与Selenium一起工作时,也非常丑陋(Primefaces)。这些都是可以做到的,但是时间有限。
如果你和UX/设计团队一起工作,并且需要快速迭代UI,你可以通过学习jquery/编写直接的HTML来节省时间,或者查看react/angular。