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/10/21 10:02:22 UTC

wicket git commit: WICKET-6190 Moved Lambda section to AJAX section

Repository: wicket
Updated Branches:
  refs/heads/master 3471de9b2 -> 12d096ccc


WICKET-6190 Moved Lambda section to AJAX section

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

Branch: refs/heads/master
Commit: 12d096ccc59aafa6d40eeeb8c40108ce24d1ee2d
Parents: 3471de9
Author: Andrea Del Bene <ad...@apache.org>
Authored: Fri Oct 21 12:01:53 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Fri Oct 21 12:01:53 2016 +0200

----------------------------------------------------------------------
 .../src/docs/guide/ajax/ajax_8.gdoc             | 47 ++++++++++++++++++--
 .../src/docs/guide/ajax/ajax_9.gdoc             |  7 +++
 wicket-user-guide/src/docs/guide/lambdas.gdoc   | 45 -------------------
 .../docs/guide/modelsforms/modelsforms_3.gdoc   |  8 +++-
 wicket-user-guide/src/docs/guide/toc.yml        |  5 +--
 5 files changed, 60 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/12d096cc/wicket-user-guide/src/docs/guide/ajax/ajax_8.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/ajax/ajax_8.gdoc b/wicket-user-guide/src/docs/guide/ajax/ajax_8.gdoc
index 83650d4..901eeb6 100644
--- a/wicket-user-guide/src/docs/guide/ajax/ajax_8.gdoc
+++ b/wicket-user-guide/src/docs/guide/ajax/ajax_8.gdoc
@@ -1,7 +1,48 @@
+Just like we have seen for links, Lambda expressions bring their benefit also to AJAX components and behaviors. Many of them come with a factory method that accepts a lambda expression to use as callback code. Here is an example for the classic and the lambda way of defining an ajax link:
 
+Classic way:
+{code}
+AjaxLink<Void> link = new AjaxLink<Void>("linkId") {
+	@Override
+	public void onClick(AjaxRequestTarget target) {
+		label.modelChanging();
+		label.setDefaultModelObject("test" + (intx++));
+		label.modelChanged();
+		target.add(label);
+	}
+}
+{code}
 
-AJAX is another example of how Wicket can simplify web technologies providing a good component and object oriented abstraction of them. 
+Using lambdas:
+{code}
+AjaxLink<Void> link = AjaxLink.onClick("linkId", target -> {
+	label.modelChanging();
+	label.setDefaultModelObject("newString");
+	label.modelChanged();
+	target.add(label);
+});
+{code}
 
-In this chapter we have seen how to take advantage of the AJAX support provided by Wicket to write AJAX-enhanced applications. Most of the chapter has been dedicated to the built-in components and behaviors that let us adopt AJAX without almost any effort. 
+Such factory methods can be found also in the utility class @Lambdas@:
 
-In the final part of the chapter we have seen how Wicket physically implements an AJAX call on client side using AJAX request attributes. Then, we have learnt how to use call listeners to execute custom JavaScript during AJAX request lifecycle.
+{code}
+import static org.apache.wicket.lambda.Lambdas.ajaxLink;
+
+...
+
+AjaxLink<Void> link = ajaxLink("linkId", target -> {
+	label.modelChanging();
+	label.setDefaultModelObject("newString");
+	label.modelChanged();
+	target.add(label);
+});
+{code}
+
+The same can be done for behaviors. For example we can create an @AjaxEventBehavior@ in this way:
+
+{code}
+  Lambdas.onEvent("click", target -> //some lambda stuf)
+{code}
+
+
+To find out other useful factory methods, you can check @Lambdas@ JavaDoc.

http://git-wip-us.apache.org/repos/asf/wicket/blob/12d096cc/wicket-user-guide/src/docs/guide/ajax/ajax_9.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/ajax/ajax_9.gdoc b/wicket-user-guide/src/docs/guide/ajax/ajax_9.gdoc
new file mode 100644
index 0000000..83650d4
--- /dev/null
+++ b/wicket-user-guide/src/docs/guide/ajax/ajax_9.gdoc
@@ -0,0 +1,7 @@
+
+
+AJAX is another example of how Wicket can simplify web technologies providing a good component and object oriented abstraction of them. 
+
+In this chapter we have seen how to take advantage of the AJAX support provided by Wicket to write AJAX-enhanced applications. Most of the chapter has been dedicated to the built-in components and behaviors that let us adopt AJAX without almost any effort. 
+
+In the final part of the chapter we have seen how Wicket physically implements an AJAX call on client side using AJAX request attributes. Then, we have learnt how to use call listeners to execute custom JavaScript during AJAX request lifecycle.

http://git-wip-us.apache.org/repos/asf/wicket/blob/12d096cc/wicket-user-guide/src/docs/guide/lambdas.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/lambdas.gdoc b/wicket-user-guide/src/docs/guide/lambdas.gdoc
deleted file mode 100644
index 82323b0..0000000
--- a/wicket-user-guide/src/docs/guide/lambdas.gdoc
+++ /dev/null
@@ -1,45 +0,0 @@
-Lambda functionalities of a lot of components are available since Wicket 8.0.0. 
-
-You are able to see if a component supports lambdas if there are methods / constructor accepting *WicketConsumer*, *WicketBiConsumer* or *WicketSupplier*, *WicketFunction*.
-
-For normal there are static methods which can be accessed to create the desired component.
-
-Here is an example for the classic and the lambda way of defining an ajax link:
-
-Classic way:
-{code}
-AjaxLink<Void> link = new AjaxLink<Void>("linkId") {
-	@Override
-	public void onClick(AjaxRequestTarget target) {
-		label.modelChanging();
-		label.setDefaultModelObject("test" + (intx++));
-		label.modelChanged();
-		target.add(label);
-	}
-}
-{code}
-
-Using lambdas:
-{code}
-AjaxLink<Void> link = AjaxLink.onClick("linkId", target -> {
-	label.modelChanging();
-	label.setDefaultModelObject("newString");
-	label.modelChanged();
-	target.add(label);
-});
-{code}
-
-or
-
-{code}
-import static org.apache.wicket.lambda.Lambdas.ajaxLink;
-
-...
-
-AjaxLink<Void> link = ajaxLink("linkId", target -> {
-	label.modelChanging();
-	label.setDefaultModelObject("newString");
-	label.modelChanged();
-	target.add(label);
-});
-{code}

http://git-wip-us.apache.org/repos/asf/wicket/blob/12d096cc/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_3.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_3.gdoc b/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_3.gdoc
index 8cf0142..e213603 100644
--- a/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_3.gdoc
+++ b/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_3.gdoc
@@ -89,7 +89,13 @@ Person person = new Person();
 IModel<String> personNameModel = new LambdaModel<>(person::getName, person::setName);
 {code}
 
-As we have seen for @Model@ also @LambdaModel@ comes with factory method @LambdaModel.of@.
+As we have seen for @Model@ also @LambdaModel@ comes with factory method @LambdaModel.of@:
+
+{code}
+Person person = new Person();
+IModel<String> personNameModel = LambdaModel.of(person::getName, person::setName);
+{code}
+
 
 h3. CompoundPropertyModel and model inheritance
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/12d096cc/wicket-user-guide/src/docs/guide/toc.yml
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/toc.yml b/wicket-user-guide/src/docs/guide/toc.yml
index b02bf80..178e32d 100644
--- a/wicket-user-guide/src/docs/guide/toc.yml
+++ b/wicket-user-guide/src/docs/guide/toc.yml
@@ -157,7 +157,8 @@ ajax:
   ajax_5: AJAX request attributes and call listeners
   ajax_6: Creating custom AJAX call listener
   ajax_7: Stateless AJAX components/behaviors
-  ajax_8: Summary
+  ajax_8: Lambda support
+  ajax_9: Summary
 jee:
   title: Integration with enterprise containers
   jee_1: Integrating Wicket with EJB
@@ -216,8 +217,6 @@ internals:
   title: Wicket Internals
   pagestoring: Page storing
   autocomponents: Markup parsing and Autocomponents
-lambdas:
-  title: Lambda Expressions
 http2push:
   title: Wicket HTTP/2 Support (Experimental)
   http2push_1: Example Usage