Apache Wicket 1.5 正式发布
Apache Wicket 团队正式发布了 Apache Wicket 1.5, 一个基于组件的开源 WEB 框架。Apache Wicket 1.5 经过两年的开发,与之前版本相比,带来无数的改进。
下载地址
-----------------------------
http://www.apache.org/dyn/closer.cgi/wicket/1.5.0
如果使用Maven,可以添加下面的代码到 POM 升级到最新版本:
<dependency> <groupId>org.apache.wicket</groupId> <artifactId>wicket-core</artifactId> <version>1.5.0</version> </dependency>
值得注意的是,Wicket 的主 artifact ID 更名为 wicket-core。
你必须升级所有的模块(i.e. wicket, wicket-extensions,
wicket-ioc, wicket-spring, etc) 到1.5.0,在使用最新版本,不要混合使用之前的版本。
值得注意的变更
--------------------
这个发布版本中,Wicket 团队对其内部进行了大量的更新。包括:
- 添加了 HTML5 组件: EmailTextField, NumberTextField, UrlTextField and
RangeTextField
- 全新的组件内事件机制 (下面会解释)
- servlet API 最低版本为 servlet-api 2.5
- 所有的标准的 validators 继承了 Behavior 以便客户端验证
- 删除 IBehavior,AbstractBehavior 标志为过时,现在你应该直接从 Behavior 继承。
- 简化请求生命周期处理,使其更有扩展性
- URL 集中处理
- Wicket’s rendering 代码大大简化
- 改进了浏览器缓存支持
- ClientSideImageMap 代替了旧的 ImageMap
- Better support for running behind proxies with x-forwarded-for header
- Request cycle listeners 使集成框架到你的 Wicket 应用中变得更加简单
- 一致的命名: 方法名的 Javascript 更名为 JavaScript
- 切换到 HTTPS 很简单,只配置一个新的 root mapper,让 Wicket 能够识别 HTTPS,在页面添加 @RequireHttps
更详细的变更和改进包含在升级指南中.
组件内部事件机制
----------------------
Wicket 1.5 offers a simple, yet flexible, way for component to communicate
with each other in a decoupled manner. The two major interfaces that
facilitate this are:
/** * Objects that can send events */ public interface IEventSource { void send(IEventSink sink, Broadcast broadcast, T payload); }
and
/** * Objects that can receive events */ public interface IEventSink { /** * Called when an event is sent to this sink */ void onEvent(IEvent> event); }
The classes that implement these interfaces, and can thus participate in the
event mechanism are: Component, RequestCycle, Session, and Application.
The mechanism allows for different event broadcast methods defined here:
/** * Defines the event broadcast type. */ public enum Broadcast { BREADTH, DEPTH, BUBBLE, EXACT; }
There is an example in wicket-examples which demonstrates the usage of this.
Applications can register custom event dispatchers in FrameworkSettings; the
dispatchers can be used to build custom event delivery mechanisms. For example
a custom IEventDispatcher mechanism can route events to annotated methods, for
example:
public class MyComponent extends Component { @OnEvent private void onUserAdded(UserAddedEvent event) {...} }
where UserAddedEvent is the event payload object.
The default Component#onEvent method will be called even if custom dispatchers
are registered.
A default event is raised whenever Wicket begins to create an AJAX response.
The payload of the event is the AjaxRequestTarget used for event. Sample
implementation:
// component that always adds itself to the ajax response public class MyComponent extends Component { public void onEvent(IEvent event) { if (event.getPayload() instanceof AjaxRequestTarget) { ((AjaxRequestTarget)event.getPayload()).add(this); } } }
推荐阅读
-
Angular发布1.5正式版,专注于向Angular 2的过渡
-
Apache Spark 3.0 预览版正式发布,多项重大功能发布
-
Apache Spark 1.5.0正式发布
-
Apache Spark 1.5.0正式发布
-
Apache APISIX 2.8 正式发布,带来更多新功能!
-
Apache APISIX 2.8 正式发布,带来更多新功能!
-
Angular发布1.5正式版,专注于向Angular 2的过渡
-
Apache Wicket 1.4.9 发布
-
Apache Jackrabbit发布1.5版本
-
Apache Wicket 6.22.0/7.2.0 发布_html/css_WEB-ITnose