You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by ad...@apache.org on 2016/06/25 17:22:53 UTC

wicket git commit: WICKET-6190 added lambda example where Link component is introduced.

Repository: wicket
Updated Branches:
  refs/heads/master ff26ad8e4 -> c391af662


WICKET-6190 added lambda example where Link component is introduced.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/c391af66
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/c391af66
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/c391af66

Branch: refs/heads/master
Commit: c391af662bd2d9633efc295e19dcf7291d9cdd89
Parents: ff26ad8
Author: Andrea Del Bene <ad...@apache.org>
Authored: Sat Jun 25 19:21:48 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Sat Jun 25 19:21:48 2016 +0200

----------------------------------------------------------------------
 .../src/docs/guide/helloWorld/helloWorld_4.gdoc         | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/c391af66/wicket-user-guide/src/docs/guide/helloWorld/helloWorld_4.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/helloWorld/helloWorld_4.gdoc b/wicket-user-guide/src/docs/guide/helloWorld/helloWorld_4.gdoc
index 1eea3a1..f4c4dae 100644
--- a/wicket-user-guide/src/docs/guide/helloWorld/helloWorld_4.gdoc
+++ b/wicket-user-guide/src/docs/guide/helloWorld/helloWorld_4.gdoc
@@ -45,6 +45,18 @@ public void onClick() {
 
 The difference between using the first version of @setResponsePage@ rather than the second one will be illustrated in [chapter 8|guide:versioningCaching], when we will introduce the topic of stateful and stateless pages. For now, we can consider them as equivalent. 
 
+Like many other Wicket components, @Link@ is lambda-friendly and comes with a factory method called @onClick@ which leverages lambda expressions to specify handler method:
+
+{code}
+public class HomePage extends WebPage {
+    public HomePage(){
+        add(Link.onClick("id", () -> setResponsePage(AnotherPage.class));
+    }
+}
+{code}
+
+The lambda expression is converted into a @org.apache.wicket.lambda.WicketConsumer@, which is basically a serializable version of @java.util.function.Consumer<T>@ (we will see later why we need it to be serializable).
+
 Wicket comes with a rich set of link components suited for every need (links to static URL, Ajax-enhanced links, links to a file to download, links to external pages and so on). We will see them in [chapter 10|guide:urls].
 
 {note}