Repository: wicket Updated Branches: refs/heads/master 6ffc5be85 -> f51b4b5c4
WICKET-6395 removed reference to no more existing factory methods for Ajax components and behaviors Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/f51b4b5c Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/f51b4b5c Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/f51b4b5c Branch: refs/heads/master Commit: f51b4b5c43d0be9707a4462eb75fa5beee61ffd5 Parents: 6ffc5be Author: Andrea Del Bene <[email protected]> Authored: Tue Jun 27 15:56:25 2017 +0200 Committer: Andrea Del Bene <[email protected]> Committed: Tue Jun 27 15:56:25 2017 +0200 ---------------------------------------------------------------------- .../src/main/asciidoc/ajax/ajax10.adoc | 9 ++++ .../src/main/asciidoc/ajax/ajax_8.adoc | 53 +++----------------- .../src/main/asciidoc/ajax/ajax_9.adoc | 34 +++++++++++-- wicket-user-guide/src/main/asciidoc/single.adoc | 6 ++- 4 files changed, 52 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/f51b4b5c/wicket-user-guide/src/main/asciidoc/ajax/ajax10.adoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/main/asciidoc/ajax/ajax10.adoc b/wicket-user-guide/src/main/asciidoc/ajax/ajax10.adoc new file mode 100644 index 0000000..b4bcb27 --- /dev/null +++ b/wicket-user-guide/src/main/asciidoc/ajax/ajax10.adoc @@ -0,0 +1,9 @@ + + + +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/f51b4b5c/wicket-user-guide/src/main/asciidoc/ajax/ajax_8.adoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/main/asciidoc/ajax/ajax_8.adoc b/wicket-user-guide/src/main/asciidoc/ajax/ajax_8.adoc index 5c9f8e4..a08e1ff 100644 --- a/wicket-user-guide/src/main/asciidoc/ajax/ajax_8.adoc +++ b/wicket-user-guide/src/main/asciidoc/ajax/ajax_8.adoc @@ -1,54 +1,15 @@ -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: +Just like we have seen for regular links, WicketStuff project offers a lambda-based factory class to build Ajax links and Ajax submitting component: -Classic way: [source,java] ---- -AjaxLink<Void> link = new AjaxLink<Void>("linkId") { - @Override - public void onClick(AjaxRequestTarget target) { - label.modelChanging(); - label.setDefaultModelObject("test" + (intx++)); - label.modelChanged(); - target.add(label); - } -} ----- - -Using lambdas: -[source,java] ----- -AjaxLink<Void> link = AjaxLink.onClick("linkId", target -> { - label.modelChanging(); - label.setDefaultModelObject("newString"); - label.modelChanged(); - target.add(label); -}); ----- - -Such factory methods can be found also in the utility class _Lambdas_: - -[source,java] ----- -import static org.apache.wicket.lambda.Lambdas.ajaxLink; - -... - -AjaxLink<Void> link = ajaxLink("linkId", target -> { - label.modelChanging(); - label.setDefaultModelObject("newString"); - label.modelChanged(); - target.add(label); -}); ----- +//create an AJAX link component +add(ComponentFactory.ajaxLink("id", (ajaxLink, ajaxTarget) -> {/*do stuff*/}); -The same can be done for behaviors. For example we can create an _AjaxEventBehavior_ in this way: - -[source,java] +//create a submit link with error handler +add(ComponentFactory.ajaxSubmitLink("id", (ajaxLink, ajaxTarget) -> {/*do submit stuff*/}, + (ajaxLink, ajaxTarget) -> {/*do error stuff*/}); ---- - Lambdas.onEvent("click", target -> //some lambda stuf) ----- - -To find out other useful factory methods, you can check _Lambdas_ JavaDoc. +For more examples see WicketStuff module <<wicketstuff_7.adoc,wicketstuff-lambda-components>>. http://git-wip-us.apache.org/repos/asf/wicket/blob/f51b4b5c/wicket-user-guide/src/main/asciidoc/ajax/ajax_9.adoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/main/asciidoc/ajax/ajax_9.adoc b/wicket-user-guide/src/main/asciidoc/ajax/ajax_9.adoc index b4bcb27..8cf5480 100644 --- a/wicket-user-guide/src/main/asciidoc/ajax/ajax_9.adoc +++ b/wicket-user-guide/src/main/asciidoc/ajax/ajax_9.adoc @@ -1,9 +1,37 @@ +Ajax behaviors classes come with lambda-based factory methods which make their creation easier and less verbose. For example AjaxEventBehavior can be instantiated like this: +[source,java] +---- + AjaxEventBehavior.onEvent("click", ajaxtarget -> //some lambda stuff) +---- +In the following table are listed these factory methods along with their behavior classes: -AJAX is another example of how Wicket can simplify web technologies providing a good component and object oriented abstraction of them. +.Factory methods +|=== +|Class Name |Method Name -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. +|AbstractAjaxTimerBehavior +|onTimer -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. +|AjaxEventBehavior +|onEvent +|AjaxNewWindowNotifyingBehavior +|onNewWindow + +|AjaxSelfUpdatingTimerBehavior +|onSelfUpdate + +|AjaxFormChoiceComponentUpdatingBehavior +|onUpdateChoice + +|AjaxFormComponentUpdatingBehavior +|onUpdate + +|AjaxFormSubmitBehavior +|onSubmit + +|OnChangeAjaxBehavior +|onChange +|=== http://git-wip-us.apache.org/repos/asf/wicket/blob/f51b4b5c/wicket-user-guide/src/main/asciidoc/single.adoc ---------------------------------------------------------------------- diff --git a/wicket-user-guide/src/main/asciidoc/single.adoc b/wicket-user-guide/src/main/asciidoc/single.adoc index 0accbba..d9ecb2f 100644 --- a/wicket-user-guide/src/main/asciidoc/single.adoc +++ b/wicket-user-guide/src/main/asciidoc/single.adoc @@ -573,10 +573,14 @@ include::ajax/ajax_6.adoc[leveloffset=+1] include::ajax/ajax_7.adoc[leveloffset=+1] -=== Lambda support +=== Lambda support for components include::ajax/ajax_8.adoc[leveloffset=+1] +=== Lambda support for behavior + +include::ajax/ajax_9.adoc[leveloffset=+1] + === Summary include::ajax/ajax_9.adoc[leveloffset=+1]
