Repository: wicket
Updated Branches:
  refs/heads/master b2e663404 -> 7da317e51


WICKET-6190 Added documentation about LambdaModel


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

Branch: refs/heads/master
Commit: 7da317e51f81c42caaf582f98034fb517d895e10
Parents: b2e6634
Author: Andrea Del Bene <[email protected]>
Authored: Fri Sep 2 17:22:16 2016 +0200
Committer: Andrea Del Bene <[email protected]>
Committed: Fri Sep 2 17:22:16 2016 +0200

----------------------------------------------------------------------
 .../docs/guide/modelsforms/modelsforms_3.gdoc    | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/7da317e5/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 b49ffcb..8cf0142 100644
--- a/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_3.gdoc
+++ b/wicket-user-guide/src/docs/guide/modelsforms/modelsforms_3.gdoc
@@ -74,6 +74,23 @@ children[0].name ...
 mapField[key].subfield ...
 {code}
 
+h3. LambdaModel
+
+@PropertyModel@ uses textual expressions to resolve object properties. That's 
nice but it comes with some drawbacks. For example the expression can not be 
checked at compile time and is not refactory-friendly. To overcome these 
problems with Wicket 8 a new kind of lambda-based model has been introduced: 
@org.apache.wicket.model.LambdaModel@. This model uses lambda expressions to 
get/set model object. Here is the signature of its constructor:
+
+{code}
+public LambdaModel(WicketSupplier<T> getter, WicketConsumer<T> setter)
+{code}
+
+In the following code we use method references to operate on a specific object 
property:
+
+{code}
+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@.
+
 h3. CompoundPropertyModel and model inheritance
 
 Class @org.apache.wicket.model.CompoundPropertyModel@ is a particular kind of 
model which is usually used in conjunction with another Wicket feature called 
model inheritance. With this feature, when a component needs to use a model but 
none has been assigned to it, it will search through the whole container 
hierarchy for a parent with an inheritable model. Inheritable models are those 
which implement interface @org.apache.wicket.model.IComponentInheritedModel@ 
and @CompoundPropertyModel@ is one of them. Once a @CompoundPropertyModel@ has 
been inherited by a component, it will behave just like a PropertyModel using 
the id of the component as property expression. As a consequence, to make the 
most of CompoundPropertyModel we must assign it to one of the containers of a 
given component, rather than directly to the component itself.
@@ -118,4 +135,4 @@ CompoundPropertyModel are particularly useful when used in 
combination with Wick
 
 {note}
 Model is referred to as static model because the result of its method 
getObject is fixed and it is not dynamically evaluated each time the method is 
called. In contrast, models like PropertyModel and CompoundProperty Model are 
called dynamic models.
-{note}
\ No newline at end of file
+{note}

Reply via email to