Hello everyone, while trying out some of the very cool new features in Wicket 8, specifically replacing PropertyModels with lambda expressions, I had a few questions coming up. Most of them have been answered by the great guide provided, but following things are still a bit unclear to me:
1) Read-Only Models Let's say I want to replace the following PropertyModel for showing the "name" property of a Person obejct in a Label new PropertyModel<String>(personModel, "name"); with a lambda expression. Which of the following would be the best approach and why? LambdaModel.of(personModel, Person::getName); personModel.map(Person::getName); personModel.flatMap(...); // not quite sure yet when to use this one. See next question as well The first two options seem to be identical at the first glance but I noticed that the LambdaModel does call detach() on the underlying base model (just like the PropertyModel does), whereas the model created by the map() method doesn't seem to do that. 2) Readable/Writeable Models The documentation has the following example for mapping a model to a readable/writeable model of a property IModel<String> personNameModel = personModel.flatMap(targetPerson -> LambdaModel.of( () -> targetPerson::getName, targetPerson::setName )); Why is the call to flatMap() needed? Isn't just using the LambdaModel the same but shorter? IModel<String> personNameModel = LambdaModel.of(personModel, Person::getName, Person::setName); 3) Constants in Models In some cases I need to set a static constant value as read only model in a component. Up until now I simply used Model.of(Constants.MY_STATIC_VALUE); which probably results in the value being serialised into the session of the user. Am I assuming correctly, that using following lambda expression as model is more "efficient", since the static constant isn't serialised anymore this way? () -> Constants.MY_STATIC_VALUE; Thanks to everybody pouring so much time into developing Wicket! Daniel Radünz -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Questions-regarding-Wicket-8-and-lambda-expressions-for-models-tp4677918.html Sent from the Users forum mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org