This looks fantastic. Can you think of an elegant way to use similar syntactic sugar to create LoadableDetachableModels as well?
For example: // This would return a PropertyModel model(from(myBean).getChild().getName()); // This a LoadableDetachableModel loadedModel(from(myService).listUsers()); // Which is more concise than new LoadableDetachableModel<List<User>> { protected List<User> load() { myService.listUsers(); } } On Jul 21, 2011, at 11:45 AM, Carl-Eric Menzel wrote: > After seeing the LambdaJ-based model idea at > https://cwiki.apache.org/WICKET/working-with-wicket-models.html#WorkingwithWicketmodels-LambdaJ > I thought I'd try and implement something like that in a ready-to-use > fashion, and simplify it a little. > > The result is here: > https://github.com/duesenklipper/wicket-safemodel > > This is a way to refactor-safely and type-safely build models, without > relying on brittle string literals: > > SomeBean myBean = ... > IModel<String> childNameModel = > model(from(myBean).getChild().getName()); > > No cast, no string literal, only getters. It works with regular > JavaBeans, Lists, and with Maps (string keys only though). > > Instead of requiring a compile-time step this does some proxying in the > background to construct a property expression. > > Anybody interested please give it a try and let me know of any issues. > > Note: If you feel comfortable with configuring an annotation > processor in your Maven build as well as your IDE build, go ahead and > try Igor's metagen [https://github.com/42Lines/metagen]. That way you > don't have any runtime magic. > > Use SafeModel if you don't want an additional compile step and do want > (very slightly) less keyboard typing. > > Carl-Eric > www.wicketbuch.de > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org