You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Dan Retzlaff <dr...@gmail.com> on 2012/10/10 19:42:33 UTC

Type-safe PropertyModel for Wicket 7

I'd like to start a thread on Dominik Drzewiecki's suggestion of a
type-safe property model improvement for Wicket 7. I've seen a few
competing solutions:

1. Igor's metagen: https://github.com/42Lines/metagen
2. Igor's bindgen-wicket: http://code.google.com/p/bindgen-wicket/
3. Carl-Eric's wicket-safemodel:
https://github.com/duesenklipper/wicket-safemodel

We use our own metagen-like solution (written before Igor's) for use in
PropertyModels and JPA/Hibernate criteria queries, but we've been eyeing...
4. Querydsl (http://www.querydsl.com/)

... as a JPA/Hibernate query alternative. To avoid redundant Maven plugins
and generated classes, I've been meaning to explore adapting Querydsl's Q*
classes into a Wicket IModel. This approach is too heavy for a Wicket
"core" feature, but I mention it because on the surface it seems like the
cleanest option for JPA-backed Wicket projects.

Is there a clear "best" here (or elsewhere)? Worst? :)
Igor, is it accurate to say that metagen supercedes bindgen-wicket?
Is it a reasonable goal for this to be a core feature, or does its probable
Maven plugin relegate it to another (experimental?) module?

Cheers,
Dan

Re: Type-safe PropertyModel for Wicket 7

Posted by Igor Vaynberg <ig...@gmail.com>.
On Wed, Oct 10, 2012 at 10:42 AM, Dan Retzlaff <dr...@gmail.com> wrote:
> I'd like to start a thread on Dominik Drzewiecki's suggestion of a
> type-safe property model improvement for Wicket 7. I've seen a few
> competing solutions:
>
> 1. Igor's metagen: https://github.com/42Lines/metagen
> 2. Igor's bindgen-wicket: http://code.google.com/p/bindgen-wicket/
> 3. Carl-Eric's wicket-safemodel:
> https://github.com/duesenklipper/wicket-safemodel
>
> We use our own metagen-like solution (written before Igor's) for use in
> PropertyModels and JPA/Hibernate criteria queries, but we've been eyeing...
> 4. Querydsl (http://www.querydsl.com/)
>
> ... as a JPA/Hibernate query alternative. To avoid redundant Maven plugins
> and generated classes, I've been meaning to explore adapting Querydsl's Q*
> classes into a Wicket IModel. This approach is too heavy for a Wicket
> "core" feature, but I mention it because on the surface it seems like the
> cleanest option for JPA-backed Wicket projects.
>
> Is there a clear "best" here (or elsewhere)? Worst? :)
> Igor, is it accurate to say that metagen supercedes bindgen-wicket?

yes. i started out working with bindgen because it offers a nice
syntax of ( a.foo().bar() ) to build expressions, but because of that
it is also very viral and generates a lot of metadata. i wrote metagen
to reduce the amount of this metadata generated, but it sacrifices on
the elegance of property expression syntax ( a.get(B.foo).get(C.bar)
), this syntax is similar to jpa's builtin metadata syntax. metagen is
a standalone project.

-igor


> Is it a reasonable goal for this to be a core feature, or does its probable
> Maven plugin relegate it to another (experimental?) module?
>
> Cheers,
> Dan

Re: Type-safe PropertyModel for Wicket 7

Posted by Pointbreak <po...@ml1.net>.
Ad 3: Like! Simple, no change to the build process necessary. If the
generated PropertyModel doesn't carry the memory footprint of the
runtime-generated bean subclass (mock) that's used for building it, I'm
going to use it in my projects. (And otherwise I'll change that...)

Ad 1: The syntax looks really nice. The virality not. The build process
neither. I don't really get why bindgen tries to limit that virality
with cumbersome and refactor-unsafe property files. Why not add
different types of annotations, or properties on annotations, e.g.
something like @Bindable(includeUnboundMembers=false) to only process
the annotated class itself, and only referenced classes that also have a
@Bindable annotation?

On Wed, Oct 10, 2012, at 19:42, Dan Retzlaff wrote:
> I'd like to start a thread on Dominik Drzewiecki's suggestion of a
> type-safe property model improvement for Wicket 7. I've seen a few
> competing solutions:
> 
> 1. Igor's metagen: https://github.com/42Lines/metagen
> 2. Igor's bindgen-wicket: http://code.google.com/p/bindgen-wicket/
> 3. Carl-Eric's wicket-safemodel:
> https://github.com/duesenklipper/wicket-safemodel
> 
> We use our own metagen-like solution (written before Igor's) for use in
> PropertyModels and JPA/Hibernate criteria queries, but we've been
> eyeing...
> 4. Querydsl (http://www.querydsl.com/)
> 
> ... as a JPA/Hibernate query alternative. To avoid redundant Maven
> plugins
> and generated classes, I've been meaning to explore adapting Querydsl's
> Q*
> classes into a Wicket IModel. This approach is too heavy for a Wicket
> "core" feature, but I mention it because on the surface it seems like the
> cleanest option for JPA-backed Wicket projects.
> 
> Is there a clear "best" here (or elsewhere)? Worst? :)
> Igor, is it accurate to say that metagen supercedes bindgen-wicket?
> Is it a reasonable goal for this to be a core feature, or does its
> probable
> Maven plugin relegate it to another (experimental?) module?
> 
> Cheers,
> Dan

Re: Type-safe PropertyModel for Wicket 7

Posted by Guillaume Smet <gu...@gmail.com>.
Hi,

On Wed, Oct 10, 2012 at 7:42 PM, Dan Retzlaff <dr...@gmail.com> wrote:
> 2. Igor's bindgen-wicket: http://code.google.com/p/bindgen-wicket/

We use a modified version of this one which inherits from
PropertyModel. PropertyModel has a few nice features, especially the
fact that it's trying to call the default constructor of the object
when it finds a null property on /set/ operations (the model of
bindgen-wicket throws an NPE). It's especially useful when you use
@Embedded/@Embeddable.

So we wrap PropertyModel into a BindingModel class and we give it the
path extracted from bindgen binding.

> This approach is too heavy for a Wicket
> "core" feature, but I mention it because on the surface it seems like the
> cleanest option for JPA-backed Wicket projects.

We use QueryDSL too. But I don't think it's a good idea to use it for
this sort of thing. The fact is that we use @Bindable on a lot of
classes/interfaces, not only our entities.

> Is there a clear "best" here (or elsewhere)? Worst? :)
> Igor, is it accurate to say that metagen supercedes bindgen-wicket?
> Is it a reasonable goal for this to be a core feature, or does its probable
> Maven plugin relegate it to another (experimental?) module?

I took a look at metagen. I prefer the fluid syntax of bindgen: it's
really nice and very efficient to use (autocompletion on the property
path is quite handy). That said, bindgen is quite complicated and IIRC
doesn't support Java 7 at the moment (according to posts on bindgen
mailing list).

It's really comfortable to have a typesafe, checked at compile time
API to deal with properties and it really changed the way we use
Wicket.

-- 
Guillaume