简体   繁体   English

Wicket或Playframework?

[英]Wicket or Playframework?

I'm totally new to Java web development and I would like to choose a good Java web framework to learn. 我是Java Web开发的新手,我想选择一个好的Java Web框架来学习。 I've found some really good echoes regarding the Apache Wicket framework and the Playframework . 我发现了一些关于Apache Wicket框架Playframework的非常好的回声。 I decided to go for one of 'em; 我决定去找其中一个; but I need to choose ;-) 但我需要选择;-)

So, what to choose and why? 那么,选择什么以及为什么?

EDIT 编辑

My requirements: 我的要求:

  • I had a good experience developing with Django, so a similar framework would be great, 我有很好的使用Django开发的经验,所以类似的框架会很棒,
  • I need a framework that can interact with other mainstream Java goodies (libraries, tools ..etc) so I can take advantage of what Java does really offer. 我需要一个可以与其他主流Java好东西(库,工具等)交互的框架,这样我就可以利用Java真正提供的功能。

Wicket and Play are two very different types of frameworks. Wicket和Play是两种截然不同的框架。

Play is a MVC framework which you probably will feel familiar with coming from Django. Play是一个MVC框架,您可能会对Django感到熟悉。 Like Django, it offers more than just the web bits and provides a JPA based ORM framework, scaffolding tools and probably a lot more (I have no practical experience with it). 像Django一样,它提供的不仅仅是Web位,还提供了基于JPA的ORM框架,脚手架工具以及可能更多(我没有实际经验)。 They have a great tutorial on their site, and you'll probably see the Django similarities there. 他们在他们的网站上有一个很棒的教程,你可能会在那里看到Django的相似之处。

Wicket is a component oriented framework (like JSF and Tapestry) and focuses heavily on object oriented design. Wicket是一个面向组件的框架(如JSF和Tapestry),并且主要关注面向对象的设计。 It's also MVC, per se, but pages are usually built by composing self-contained and reusable components (View and Controller, pluggable Models). 它本身也是MVC,但页面通常是通过组合自包含和可重用的组件(View和Controller,可插拔模型)构建的。 These components can be extended by standard inheritance and composition and markup is very cleanly separated from code and easily modified. 这些组件可以通过标准继承和组合进行扩展,并且标记与代码非常清晰地分开并且易于修改。

Wicket can manage event callbacks and state automatically, so that you don't have to think urls at all, no matter how complex your page is. 检票可以自动管理事件的回调和状态,这样你就不必想的网址可言,不管你的网页是多么复杂。 A quick example for a clickable button that goes a away when it's clicked (very useful): 一个可点击按钮的快速示例,当点击它时非常有用(非常有用):

  // In a page constructor
  add(new Link("link") {
        public void onClick() {
          setVisible(false);
        }
    });

I want to emphasize that you don't have to use server-side state, and that it's quite possible to use Wicket as a "normal" MVC framework if you want to (and yes, it's easy to get pretty urls). 我想强调一点,你不必使用服务器端状态,并且如果你愿意的话,很可能将Wicket用作“普通”MVC框架(是的,它很容易得到漂亮的URL)。

The Wicket project focuses only on the core web framework and there are no extra "niceties" such as special ORM support or scaffolding. Wicket项目仅关注核心Web框架,并且没有额外的“细节”,例如特殊的ORM支持或脚手架。 I personally agree with the Wicket project's philosophy here, but for new developers coming to the framework, doing "simple" stuff such as a sortable and pageable table can be a bit daunting as pre-built components are a bit scarce. 我个人同意Wicket项目的理念,但是对于进入框架的新开发人员来说,做一些“简单”的东西,比如可排序和可分页的表格可能有点令人生畏,因为预构建的组件有点稀缺。 The learning and productivity curve for Wicket can be a bit steep, but the upside is that once you've made components (and "behaviours" - longer story) that fit your needs, they are extremely reusable. Wicket的学习和生产力曲线可能有点陡峭,但好处是,一旦你制作了符合你需求的组件(和“行为” - 更长的故事),它们就是非常可重复使用的。

Although I personally love Wicket, I have a hunch that you probably will be best off with Play. 虽然我个人喜欢Wicket,但我有一种预感,你可能会玩Play最好。 Your question indicates that you want a "Django" with access to Java libs, and in that case I think Play (or some other Java MVC) is the safe choice. 你的问题表明你想要一个可以访问Java库的“Django”,在这种情况下,我认为Play(或其他一些Java MVC)是安全的选择。 On the other hand, maybe you've been using Django because you didn't know how incredibly powerful Wicket is. 另一方面,也许你一直在使用Django,因为你不知道Wicket有多么强大。 ;) If you give some more info on your project, we'll be able to give a more qualified response. ;)如果您提供有关项目的更多信息,我们将能够提供更合格的回复。

As a side-node: As Play is not very mainstream (at least for now), I'd also consider Grails which has strong commercial backing and even more out-of-the-box modules. 作为一个侧节点:由于Play不是很主流(至少目前为止),我还会考虑Grails ,它具有强大的商业支持和更多开箱即用的模块。

Play! 玩! is designed to be comfortable for developers coming from scripting languages like Python and PHP. 适用于来自Python和PHP等脚本语言的开发人员。 It provides its own build system and management scripts, somewhat like Rails or Django would. 它提供了自己的构建系统和管理脚本,有点像Rails或Django。 Existing build tools and infrastructure (like the Maven repositories commonly used for dependency management in Java-land) will not integrate well with Play. 现有的构建工具和基础结构(如通常用于Java-land中的依赖关系管理的Maven存储库)将无法与Play良好集成。

Wicket will be more comfortable for developers coming from desktop development in Java. 对于来自Java桌面开发的开发人员来说,Wicket会更加舒适。 It doesn't provide special tooling, so it will be easier to integrate into a specific build tool if you have a preference (and there are many build tools providing things like automated dependency retrieval available in the Java ecosystem.) 它不提供特殊工具,因此如果您有偏好,将更容易集成到特定的构建工具中(并且有许多构建工具提供Java生态系统中可用的自动依赖项检索等功能。)

So there's quite some difference between the two options :) If you can figure out which experience would benefit you most, the decision should be pretty clear from there. 所以这两个选项之间存在很大差异:)如果你能找出最有利于你的经历,那么决定应该很清楚。

If your system is only for Web tier , Play! 如果您的系统仅适用于Web层,请播放! framework is very suitable. 框架非常合适。 But , if your data models are not just for web , maybe exported as REST by Spring with CXF , and consumed by GWT or other web services , and you want to make sure the consistent states with web tier , Wicket (with Spring/hibernate) is a good choice. But ,如果您的数据模型不仅仅适用于Web,可能exported as REST by Spring with CXF ,并由GWT或其他Web服务使用,并且您希望确保与Web层,Wicket(使用Spring / hibernate)的一致状态是个不错的选择。

Something I don't feel so good about Play! 我对Play的感觉不太好! is the caching mechanism. 是缓存机制。 You have to manually naming/insert/retrieve/invalidate/purge cache . 您必须手动命名/插入/检索/无效/清除缓存。 This will make the whole architecture error-prone. 这将使整个架构容易出错。 While wicket with spring/JPA(hibernate)/ehcache(or other providers) , you can define consistent caching/dao layer for upper layer (web/REST...) , which will not impose state inconsistencies. 使用spring / JPA(hibernate)/ ehcache(或其他提供程序)的wicket时,可以为上层(web / REST ...)定义一致的缓存/ dao层,这不会强加状态不一致。

Another advantage with wicket is it has built-in AJAX support backed by Java . wicket的另一个优点是它具有Java支持的内置AJAX支持。 Although these AJAX's states are maintained in the server side (and maybe a little sluggish) , if you don't want to learn JavaScript , you can still build a 'not-so-bad' AJAX page . 虽然这些AJAX的状态是在服务器端维护的(可能有点迟钝),但如果你不想学习JavaScript,你仍然可以构建一个“不那么糟糕”的AJAX页面。

With Play! 随着玩! , If you don't know about JS , and don't want to learn it , don't want to manipulate cumbersome DOMs , you can only build an 'average' site. ,如果你不了解JS,并且不想学习它,不想操纵繁琐的DOM,你只能建立一个“普通”的网站。 OTOH , if you are skilled with JS / jQuery , you can choose Play! OTOH,如果你熟悉JS / jQuery,你可以选择Play! .

I'm using PLay! 我正在使用PLay! a lot and have used Wicket for a bit of evaluation. 很多,并使用Wicket进行一些评估。 My experience is, that you have to write a lot more code to get the same work done with Wicket. 我的经验是,您必须编写更多代码才能完成与Wicket相同的工作。 You have more "indirection" with Wicket. 你对Wicket有更多的“间接”。 I personally prefer code that has as little as possible "ceremony" and that is easy to follow. 我个人更喜欢尽可能少的“仪式”代码,这很容易理解。

The Play! 表演! architects are also adding Scala support to Play!, which I think is a great idea, since Scala is fully interoperable with Java code and libraries but by far more advanced then Java. 建筑师也在为Play!添加Scala支持,我认为这是一个好主意,因为Scala可以与Java代码和库完全互操作,但远比Java先进。

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

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