java JSF 与 JavaFX:优点和缺点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7407143/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 19:49:43  来源:igfitidea点击:

JSF vs JavaFX : Pros & Cons

javajsfjakarta-eejavafx

提问by IAmYourFaja

I have read the Wikipedia article on JavaFX and several other articles and I believeI have a decent understanding of what it is and what it does.

我已经阅读了关于 JavaFX 的维基百科文章和其他几篇文章,我相信我对它是什么以及它的作用有一个很好的理解。

My question is simple: what do Java EE best practices dictate one uses for the presentation? Or, is it possible to use them both? Either way, can someone give an example of when it would be appropriate to choose one over the other, and why?

我的问题很简单:Java EE 最佳实践决定了演示文稿的一种用途?或者,是否可以同时使用它们?无论哪种方式,有人可以举一个例子说明什么时候选择一个比较合适,为什么?

Thanks for any help with this; I'm just not seeing why anyone would ever want/need to stray from JSF.

感谢您对此的任何帮助;我只是不明白为什么有人会想要/需要偏离 JSF。

回答by digitaljoel

JavaFX and JSF are two very different animals. I think of JavaFX as Oracle's version of Adobe Flex (or Flash?). It runs on a JVM, which means it's a heavier client for the browser. JSF uses standard HTML controls and interaction.

JavaFX 和 JSF 是两种截然不同的动物。我认为 JavaFX 是 Oracle 的 Adob​​e Flex(或 Flash?)版本。它在 JVM 上运行,这意味着它是浏览器的一个更重的客户端。JSF 使用标准的 HTML 控件和交互。

Running in a VM, like JavaFX or Flex means that you don't have to worry as much about browser capabilities like you do with standard HTML/Javascript, but it also means you are at the mercy of the VM implementor to get the platform on browser XYZ and fix platform and security bugs as they arrive. Another consideration is that some corporate environments may not like allowing plugins like flash/java in the browser.

在 VM 中运行,例如 JavaFX 或 Flex 意味着您不必像使用标准 HTML/Javascript 那样担心浏览器功能,但这也意味着您要受 VM 实现者的支配才能使平台运行浏览器 XYZ 并在平台和安全漏洞出现时修复它们。另一个考虑因素是一些企业环境可能不喜欢在浏览器中允许插件如 flash/java。

Running pure HTML/Javascript will likely get you going on more devices and is lighter weight than needing to load a VM into the browser (never thought I would call JSF 'lighter weight'.) jQuery and other javascript frameworks have lessened the worries about cross-browser compatibility somewhat but not completely.

运行纯 HTML/Javascript 可能会让你在更多设备上运行,并且比需要将 VM 加载到浏览器中更轻(从没想过我会称 JSF 为“轻量级”。)jQuery 和其他 javascript 框架减少了对交叉的担忧- 浏览器兼容性有些但不完全。

So, the answer is the same here as it is for every other question like this: "It Depends." What are your needs? Are you doing an annoying restaurant website where you feel like the menu (even though it's just an image) needs to be loaded by a heavy plugin? Perhaps JavaFX will fit the bill. Are you doing a simple CRUD app and you want to complicate things by using a difficult component based framework? JSF can help you with that.

因此,这里的答案与其他类似问题的答案相同:“视情况而定”。你有什么需求?您是否正在做一个烦人的餐厅网站,您觉得菜单(即使它只是一个图像)需要通过一个繁重的插件加载?也许 JavaFX 会符合要求。您是否正在开发一个简单的 CRUD 应用程序,并且想要通过使用一个困难的基于组件的框架来使事情复杂化?JSF 可以帮助您解决这个问题。

回答by Smart Coder

JSF is pretty rich in UI compared to spring or struts but has a jargon of maintaining session and additional jars. But if you use richfaces, ibmfaces or primefaces your life will be much easier. JSF is a specification and you need to use its implementations like richfaces or myfaces.

与 spring 或 struts 相比,JSF 的 UI 非常丰富,但有维护会话和其他 jars 的术语。但是,如果您使用richfaces、ibmfaces 或primefaces,您的生活会容易得多。JSF 是一种规范,您需要使用它的实现,如richfaces 或myfaces。