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/07/14 14:04:58 UTC

wicket git commit: WICKET-6190 added a section for IModel Lambda functionalites.

Repository: wicket
Updated Branches:
  refs/heads/master abbd93f04 -> 0006d353f


WICKET-6190 added a section for IModel Lambda functionalites.

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

Branch: refs/heads/master
Commit: 0006d353fbf98eb4326d64ee69dfc9ef6811b0b7
Parents: abbd93f
Author: Andrea Del Bene <ad...@apache.org>
Authored: Thu Jul 14 16:03:28 2016 +0200
Committer: Andrea Del Bene <ad...@apache.org>
Committed: Thu Jul 14 16:04:30 2016 +0200

----------------------------------------------------------------------
 wicket-user-guide/scripts/_Events.groovy        | 20 +++++++++++++++
 wicket-user-guide/src/docs/css/custom.css       |  3 +++
 .../docs/guide/modelsforms/modelsforms_2.gdoc   | 27 ++++++++++++++++++--
 3 files changed, 48 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/0006d353/wicket-user-guide/scripts/_Events.groovy
----------------------------------------------------------------------
diff --git a/wicket-user-guide/scripts/_Events.groovy b/wicket-user-guide/scripts/_Events.groovy
index 34fa4f6..6c9d8fd 100644
--- a/wicket-user-guide/scripts/_Events.groovy
+++ b/wicket-user-guide/scripts/_Events.groovy
@@ -45,6 +45,26 @@ eventDocStart = { kind ->
           }
         })
         
+        org.radeox.macro.MacroLoader.newInstance().add(
+            org.radeox.macro.MacroRepository.instance,
+            new org.radeox.macro.Preserved() {
+    
+              @Override
+              String getName() {
+                'divcontainer'
+              }
+              
+              @Override
+              void execute(Writer writer, org.radeox.macro.parameter.MacroParameter params) {
+                def content = params.content
+                def tagValue = params.get("0")
+                
+                writer << "<div class=\"" + tagValue + "\">"
+                writer << content
+                writer << "</div>"
+              }
+            })
+        
         println "macro externalink added"
     }
 }

http://git-wip-us.apache.org/repos/asf/wicket/blob/0006d353/wicket-user-guide/src/docs/css/custom.css
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/css/custom.css b/wicket-user-guide/src/docs/css/custom.css
index 735b223..1d14f7e 100644
--- a/wicket-user-guide/src/docs/css/custom.css
+++ b/wicket-user-guide/src/docs/css/custom.css
@@ -57,3 +57,6 @@ h1, h2, #main a, #main .project strong, .local .local-title .toggle a, #table-of
    #col2 {display:none!important;}
   }
 
+.li-nested-content {
+	margin: .75em 0 .75em 32px
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/0006d353/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_2.gdoc
----------------------------------------------------------------------
diff --git a/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_2.gdoc b/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_2.gdoc
index 27e875e..d092350 100644
--- a/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_2.gdoc
+++ b/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_2.gdoc
@@ -9,7 +9,7 @@ add(new Label("timeStamp", () -> new Date().toString()));
 
 As mentioned above, method @setObject()@ comes with a default implementation. The code is the following:
  
-{code}
+{code:java}
 default void setObject(final T object)
 {
   throw new UnsupportedOperationException(
@@ -17,4 +17,27 @@ default void setObject(final T object)
 }
 {code}
 
-This means that models obtained using @IModel@ as lambda expressions are _read-only_. When we work with forms we need to use a model that support also data storing. In the next paragraph we will see a couple of models shipped with Wicket that allow us to easily use JavaBeans as backing objects.
\ No newline at end of file
+This means that models obtained using @IModel@ as lambda expressions are _read-only_. When we work with forms we need to use a model that support also data storing. In the next paragraph we will see a couple of models shipped with Wicket that allow us to easily use JavaBeans as backing objects.
+
+h3. Lambda Goodies
+
+Most of the default methods we find in @IModel@ are meant to leverage Lambda expressions to transform model object. The following is a short reference for such methods:
+
+* *filter(predicateFilter)*: Returns a @IModel@ checking whether the predicate holds for the contained object, if it is not null. If the predicate doesn't evaluate to true, the contained object will be null. Example:
+    {divcontainer:li-nested-content}   
+       {code:java}
+       //the filtered model will have a null model object if person's name 
+       //is not "Jane"
+       IModel<Person> janeModel = Model.of(person)
+                       .filter((p) -> p.getName().equals("Jane"));
+       {code}
+    {divcontainer}
+* *map(mapperFunction)*: Returns a @IModel@ applying the given mapper to the contained object, if it is not null. Example:
+    {divcontainer:li-nested-content}   
+        {code:java}
+        //the new model will contain the person's first name
+        IModel<String> personNameModel = Model.of(person).map(Person::getName);
+        {code}
+    {divcontainer}
+    
+ TODO:add other methods   
\ No newline at end of file