java Apache Wicket 有哪些优势?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/544049/
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
What are the advantages of Apache Wicket?
提问by dtc
I'm not a Java developer so I might get some terms wrong... but.
我不是 Java 开发人员,所以我可能会弄错一些术语......但是。
An application I integrate with is moving from Spring to Wicket. While it should not affect my integration with it I got to wondering why they would do this?
我集成的一个应用程序正在从 Spring 迁移到 Wicket。虽然它不应该影响我与它的集成,但我想知道他们为什么要这样做?
From what I know Spring is the more popular framework. I know nothing about it except it's popular. I did read the Wicket page and Wicket seems really simple and straightforward.
据我所知,Spring 是更流行的框架。我对它一无所知,除了它很受欢迎。我确实阅读了 Wicket 页面,Wicket 看起来非常简单明了。
What are some of the advantages of Wicket?
Wicket 有哪些优点?
It seems to me that changing your entire framework would be some work so I wonder if Wicket offers something that Spring does not?
在我看来,更改整个框架需要一些工作,所以我想知道 Wicket 是否提供了 Spring 没有的功能?
回答by whaley
Advantages that often get touted in circles I frequent are:
在我常去的圈子里经常被吹捧的优点是:
- Your html can be fully xhtml compliant - there is a VERY nice separation of presentation and logic in that the only thing your presentation/html layer needs to know about wicket are wicketid attributes in standard html tags. This is wonderful for the html/css/javascript client side guy on your team who does little to no actual java work. No other java based web framework can claim this, afaik.
- No xml config for anything wicket specific - everything can be done in source and very little needs to be done to the standard web.xml for your .war
- component based development is pretty easy to grok - especially if you have a non web background (e.g. a swing programmer). it encourages reuse quite a bit more than mvc does, imo.
- 您的 html 可以完全符合 xhtml - 表示和逻辑的分离非常好,因为您的表示/html 层唯一需要了解 wicket 的是标准 html 标签中的 wicketid 属性。这对于您团队中几乎不做实际 Java 工作的 html/css/javascript 客户端人员来说非常棒。没有其他基于 Java 的 Web 框架可以声明这一点,afaik。
- 没有针对任何特定于 wicket 的 xml 配置 - 一切都可以在源代码中完成,并且几乎不需要对 .war 的标准 web.xml 进行任何操作
- 基于组件的开发非常容易理解 - 特别是如果您有非 Web 背景(例如 Swing 程序员)。它比 mvc 更鼓励重用,imo。
回答by code_fish
Here are some features of apache wicket:
以下是 apache wicket 的一些功能:
POJO Component Model
POJO 组件模型
Pages and Components in Wicket are real Java objects that support encapsulation, inheritance and events.
Wicket 中的页面和组件是真正的 Java 对象,支持封装、继承和事件。
Ease of Development
易于开发
Because Wicket is Java and HTML, you can leverage what you know about Java or your favorite HTML editor to write Wicket applications.
因为 Wicket 是 Java 和 HTML,所以您可以利用您对 Java 的了解或您最喜欢的 HTML 编辑器来编写 Wicket 应用程序。
Separation of Concerns
关注点分离
Wicket does not mix markup with Java code and adds no special syntax to your markup files. The worlds of HTML and Java are parallel and associated only by Wicket ids, which are attributes in HTML and Component properties in Java. Since Wicket HTML is just HTML and Wicket Java is just Java, coders and designers can work independently to a large degree and without relying on any special tools.
Wicket 不会将标记与 Java 代码混合在一起,并且不会向您的标记文件添加任何特殊语法。HTML 和 Java 的世界是平行的,并且仅通过 Wicket id 关联,Wicket id 是 HTML 中的属性和 Java 中的组件属性。由于 Wicket HTML 只是 HTML 而 Wicket Java 也只是 Java,因此编码人员和设计人员可以在很大程度上独立工作,而无需依赖任何特殊工具。
Secure
安全的
Wicket is secure by default. URLs do not expose sensitive information and all component paths are session-relative. Explicit steps must be taken to share information between sessions. Furthermore URL encryption allows highly secure web sites.
默认情况下,Wicket 是安全的。URL 不公开敏感信息,所有组件路径都是会话相关的。必须采取明确的步骤在会话之间共享信息。此外,URL 加密允许高度安全的网站。
Transparent, Scalable Clustering Support
透明、可扩展的集群支持
All Wicket applications will work on a cluster automatically and without additional work. Once bottlenecks are understood, Wicket enables tuning of page state replication. The next version of Wicket will support client-side models for zero-state scalability.
所有 Wicket 应用程序都将自动在集群上运行,无需额外工作。一旦理解了瓶颈,Wicket 就可以调整页面状态复制。下一版本的 Wicket 将支持客户端模型以实现零状态可扩展性。
Transparent Back Button Support
透明后退按钮支持
Wicket supports configurable page version management. When users submit a form or follow a link from a page they accessed with the back button in their browser, Wicket is able to revert the page object to the state it was in when the page was originally rendered. This means you can write web applications that support the back button with very little work.
Wicket 支持可配置的页面版本管理。当用户提交表单或点击他们使用浏览器中的后退按钮访问的页面的链接时,Wicket 能够将页面对象恢复到页面最初呈现时的状态。这意味着您只需很少的工作就可以编写支持后退按钮的 Web 应用程序。
Multi-tab and multi-window support
多标签和多窗口支持
Wicket provides an easy way to write application that supports multi-window and multi-tab usage allowing developer to react properly when users open new browser window or tab
Wicket 提供了一种简单的方法来编写支持多窗口和多标签使用的应用程序,允许开发人员在用户打开新的浏览器窗口或标签时做出正确的反应
Reusable Components
可重用组件
Reusable components in Wicket are particularly easy to create. Not only can you extend existing components with the Java extends keyword, but you can also create Panel components which associate a group of components as a reusable unit.
Wicket 中的可重用组件特别容易创建。您不仅可以使用 Java extends 关键字扩展现有组件,还可以创建将一组组件关联为可重用单元的 Panel 组件。
Simple, Flexible, Localizable Form Validation
简单、灵活、可本地化的表单验证
It is trivial to write and use validators in Wicket. It is also quite easy to customize and localize the display and content of validation error messages.
在 Wicket 中编写和使用验证器很简单。自定义和本地化验证错误消息的显示和内容也很容易。
Typesafe Sessions
类型安全会话
Wicket eliminates the need to manage HttpSession attributes by hand. Page and component objects are transparently stored in the session and your application can create a custom session subclass with typesafe properties as well. All objects stored in the session can automatically participate in clustering replication.
Wicket 消除了手动管理 HttpSession 属性的需要。页面和组件对象透明地存储在会话中,您的应用程序也可以创建具有类型安全属性的自定义会话子类。会话中存储的所有对象都可以自动参与集群复制。
Factory Customizable
工厂可定制
Wicket is very extensible. Most operations are customizable through factories or factory methods.
Wicket 是非常可扩展的。大多数操作都可以通过工厂或工厂方法进行定制。
Detachable Models
可拆卸模型
Model objects in Wicket can be very lightweight in terms of memory and network use in a cluster. When a model is used, it can “attach”, populating itself with information from persistent storage. When the model is no longer in use, transient information can be reset, reducing the size of the object.
Wicket 中的模型对象在集群中的内存和网络使用方面可以非常轻量级。当一个模型被使用时,它可以“附加”,用来自持久存储的信息填充自己。当模型不再使用时,可以重置瞬态信息,减小对象的大小。
Border Components
边框组件
Wicket Border components enable the decoration of pages in a reusable fashion. This is especially useful for inheritance of common navigational structures or layout.
Wicket Border 组件能够以可重用的方式装饰页面。这对于通用导航结构或布局的继承特别有用。
Support for All Basic HTML Features
支持所有基本 HTML 功能
Wicket supports image tags, links, forms and everything else that you're used to using in your web application development.
Wicket 支持图像标签、链接、表单以及您在 Web 应用程序开发中习惯使用的所有其他内容。
Programmatic Manipulation of Attributes
属性的程序化操作
Wicket Components can programmatically change any HTML tag attribute.
Wicket 组件可以以编程方式更改任何 HTML 标记属性。
Automatic Conversions
自动转换
Once a Form validates, the model can be updated using Wicket converters. Most ordinary conversions are built-in and it is easy to write new converters.
表单验证后,可以使用 Wicket 转换器更新模型。大多数普通转换都是内置的,很容易编写新的转换器。
Dynamic Images
动态图像
Wicket makes image use, sharing and generation very easy. Dynamic images can be created by simply implementing a paint method.
Wicket 使图像的使用、共享和生成变得非常容易。可以通过简单地实现绘画方法来创建动态图像。
Pageable ListView
可分页列表视图
ListViews in Wicket are extremely powerful. You can nest any kind of component in a ListView row, even other ListViews. PageableListView supports navigation links for the large lists.
Wicket 中的 ListViews 非常强大。您可以在 ListView 行中嵌套任何类型的组件,甚至是其他 ListView。PageableListView 支持大列表的导航链接。
Tree Component
树组件
Out of the box tree component for navigating and selecting nodes.
用于导航和选择节点的开箱即用的树组件。
Localization
本土化
HTML pages, images and resource strings can all be localized.
HTML 页面、图像和资源字符串都可以本地化。
回答by tpdi
Spring's more than Spring MVC. You can (and probably should) use Spring withWicket.
Spring 不仅仅是 Spring MVC。您可以(并且可能应该)将 Spring与Wicket 结合使用。
回答by Volksman
Wicket rocks!
检票口岩石!
Spring (the UI part of which is called Spring MVC) just seems to be a mega, 'do everything, including the kitchen sink', type of framework which made it appear huge and unwieldy to me when I started to evaluate Spring (and Spring MVC). Today Spring doesn't seem to me to be focussed on any one thing. Originally I think it was simply a dependency injection framework but it quickly grew to try to be all things to all people and the simplicity was lost.
Spring(它的 UI 部分被称为 Spring MVC)似乎是一个巨大的,“做任何事情,包括厨房水槽”,当我开始评估 Spring(和 Spring MVC)。今天春天在我看来似乎不专注于任何一件事。最初我认为它只是一个依赖注入框架,但它很快就发展成为面向所有人的所有东西,并且失去了简单性。
The books I read on Spring had examples that contained way too much XML config. Errors in XML config files are a lot harder to debug and fix than errors in java code which you can single step through with your debugger.
我读过的关于 Spring 的书籍中有包含太多 XML 配置的示例。XML 配置文件中的错误比 Java 代码中的错误更难调试和修复,您可以使用调试器单步调试。
What's wrong with declaring stuff in Java code instead of XML anyway? Since when did someone decree that everything should be declared in XML anyway? If you like swimming in a sea of complex XML config files then go with Spring. If you like getting work done and being productive then go with Wicket.
无论如何,用 Java 代码而不是 XML 声明东西有什么问题?从什么时候开始有人下令无论如何都应该用 XML 声明所有内容?如果您喜欢在复杂的 XML 配置文件的海洋中畅游,那么请选择 Spring。如果您喜欢完成工作并提高工作效率,那么请选择 Wicket。
Wicket is very focussed on being the best Java based UI framework for web app development. It doesn't try to lock you into any particular dependency injection framework or any particular persistence framework (use it with JDO/JPA, DataNucleus, Hibernate, whatever).
Wicket 非常专注于成为用于 Web 应用程序开发的最佳基于 Java 的 UI 框架。它不会试图将您锁定在任何特定的依赖注入框架或任何特定的持久性框架中(将它与 JDO/JPA、DataNucleus、Hibernate 等一起使用)。
It's focus is clearly on UI but you can use any dependency injection framework you like (you don't have to use Spring's DI with it but you can if you want). We even use our own DI (http://www.expojo.com) with Wicket and all is funky.
它的重点显然是 UI,但您可以使用任何您喜欢的依赖项注入框架(您不必使用 Spring 的 DI,但如果您愿意,您可以使用它)。我们甚至使用我们自己的 DI ( http://www.expojo.com) 和 Wicket,一切都很时髦。
回答by duffymo
Spring is more all-encompassing than Wicket.
Spring 比 Wicket 更包罗万象。
Wicket is a Java web UI framework. Spring has one as well, along with modules for persistence, remoting, security, messaging, etc.
Wicket 是一个 Java Web UI 框架。Spring 也有一个,以及用于持久性、远程处理、安全性、消息传递等的模块。
Spring is built on dependency injection and AOP. Wicket has neither.
Spring 建立在依赖注入和 AOP 之上。Wicket 两者都没有。
I have not used it, but it's supposed to be simple. I can't say whether Spring is easier or harder.
我没有用过它,但它应该很简单。我不能说 Spring 是更容易还是更难。
You can use Spring to good advantage in a lot of situations besides web applications.
除了 Web 应用程序之外,您还可以在许多情况下使用 Spring。
回答by Eelco
You can read about the advantages of using Wicket in the free first chapter of Wicket In Action: http://www.manning.com/dashorst/
您可以在 Wicket In Action 的免费第一章中了解使用 Wicket 的优势:http: //www.manning.com/dashorst/
In short, Wicket is a great framework when the application you're developing is relatively complex, you want it to be maintainable, being able to scale the team and take advantage of reuse. Object oriented programming proved to be a very useful paradigm for programming UIs, but unfortunately, most Java frameworks for developing web applications, including Spring MVC, only support a very procedural programming model where they tag the term MVC on to make it sound cool (but in fact, since the granularity they support are request/ response roundtrips rather than self contained widgets, MVC is really misleading).
简而言之,当您正在开发的应用程序相对复杂、您希望它可维护、能够扩展团队并利用重用时,Wicket 是一个很好的框架。面向对象的编程被证明是一种非常有用的 UI 编程范式,但不幸的是,大多数用于开发 Web 应用程序的 Java 框架,包括 Spring MVC,只支持非常程序化的编程模型,他们在其中标记了术语 MVC 以使其听起来很酷(但事实上,由于它们支持的粒度是请求/响应往返而不是自包含的小部件,因此 MVC 确实具有误导性)。
The DI part of Spring is great, and is something you can easily use together with Wicket.
Spring 的 DI 部分很棒,您可以轻松地将其与 Wicket 一起使用。
回答by Andrew Fielden
I agree with the answers provided so far. What hasn't been mentioned are the following points, which are a consequence of Wicket's approach of web application development focussed on Java code:-
我同意到目前为止提供的答案。没有提到的是以下几点,这是 Wicket 专注于 Java 代码的 Web 应用程序开发方法的结果:-
- Wicket development does not involve writing JSPs.
- AJAX components can be developed without involving the writing of Javascript.
- Wicket 开发不涉及编写 JSP。
- 无需编写Javascript即可开发AJAX组件。
I haven't come across any other framework which takes this Java-centric approach. All the others I've used (Struts, Spring) involve JSP development.
我还没有遇到过采用这种以 Java 为中心的方法的任何其他框架。我使用过的所有其他工具(Struts、Spring)都涉及 JSP 开发。
For me a big advantage of Wicket is the focus on Java, and availablity of rich development environment tools like Eclipse. Also the very clean separation of business logic from presentation aspects of the application.
对我来说,Wicket 的一大优势是专注于 Java,以及丰富的开发环境工具(如 Eclipse)的可用性。业务逻辑与应用程序的表示方面也非常干净地分离。
回答by Frank Silbermann
Spring gives you the MVC design pattern only at the page level -- a very coarse level of granularity indeed. Wicket, in contrast, gives you the MVC design pattern at the individual component level (much as Swing offers for fat client programming). With Spring MVC, all of a form's data is global to the entire front servlet, so there is not much opportunity for information hiding, loose coupling, or tight cohesion. With Wicket, your display logic can be much more modular -- the data managed by componentA need not be visible to the code for componentB.
Spring 仅在页面级别为您提供 MVC 设计模式——确实是一个非常粗略的粒度级别。相比之下,Wicket 为您提供了单个组件级别的 MVC 设计模式(很像 Swing 提供的胖客户端编程)。使用 Spring MVC,表单的所有数据对于整个前端 servlet 都是全局的,因此信息隐藏、松散耦合或紧密内聚的机会不多。使用 Wicket,您的显示逻辑可以更加模块化——componentA 管理的数据不需要对 componentB 的代码可见。
The smaller level of granularity makes it much easier to reuse display code across a number of different web pages or even across web applications.
更小的粒度级别使得在多个不同的网页甚至 Web 应用程序中重用显示代码变得更加容易。
Also, because component configuration is done in Java rather than XML, they can be configured on-the-fly at run-time, making for much greater power and flexibility (as contrasted with most other component-oriented frameworks such as ASP.NET Web Forms or Java Server Faces).
此外,因为组件配置是用 Java 而不是 XML 完成的,它们可以在运行时即时配置,从而提供更大的功能和灵活性(与大多数其他面向组件的框架相比,如 ASP.NET Web表单或 Java Server Faces)。
回答by Sheng Chien
Some advantages of Wicket I like:
我喜欢 Wicket 的一些优点:
- Simplicity - Learning curve is small especially if you are from Swing school.
- Clean Separation of Concerns - Web designer does not need to know much about the codes.
Ease of Deployment.
- 简单 - 学习曲线很小,特别是如果您来自 Swing 学校。
- Clean Separation of Concerns - 网页设计师不需要对代码了解太多。
易于部署。
回答by Kamran
One other advantage of Wicket over other popular java web frameworks is that it allows you to create modular and extensible web applications. This is particularly useful when you are designing a web based product, which you intend to extend by adding extra functionality and pages in the form of plugins at deploy time, and eliminating the impact on the core functionality/source of your product. Here is a very good article on it.
与其他流行的 Java Web 框架相比,Wicket 的另一个优点是它允许您创建模块化和可扩展的 Web 应用程序。这在您设计基于 Web 的产品时特别有用,您打算通过在部署时以插件的形式添加额外的功能和页面来扩展该产品,并消除对产品核心功能/源的影响。这是一篇关于它的非常好的文章。

