You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Matej Knopp <ma...@gmail.com> on 2008/07/01 13:19:23 UTC

Re: generics

There is one thing that helped me quite a lot when migration the
project I'm working out. I've created GenericPanel,
GenericWebMarkupContainer and GenericFragment classes. In most cases
the only change was renaming Panel<MyClass> to GenericPanel<MyClass>.

I was wondering, even though those classes were farily simple, we
might want to include them in Wicket anyway, for the sake of
consistency and convenience.

-Matej

On Mon, Jun 30, 2008 at 12:28 PM, Johan Compagner <jc...@gmail.com> wrote:
> i looked through the code and it is fine by me.
> Lets test this then in a Build and see what people think of this.
>
>
> On Mon, Jun 30, 2008 at 8:54 AM, Igor Vaynberg <ig...@gmail.com>
> wrote:
>
>> unit tests are fixed...
>>
>> -igor
>>
>> On Sun, Jun 29, 2008 at 11:16 PM, Martijn Dashorst
>> <ma...@gmail.com> wrote:
>> > I'm guessing somewhere this week or so. We need to flush out the unit
>> > test failures and get some preliminary feedback. Also we need to have
>> > time available to actually build the release.
>> >
>> > My time is limited because we're in the final stages before publishing
>> > and I have to read our book twice or so.
>> >
>> > Martijn
>> >
>> > On Mon, Jun 30, 2008 at 2:36 AM, James Carman
>> > <ja...@carmanconsulting.com> wrote:
>> >> What sort of time frame are we looking at for a release with this new
>> >> generics paradigm?
>> >>
>> >> On Sun, Jun 29, 2008 at 3:54 PM, Igor Vaynberg <ig...@gmail.com>
>> wrote:
>> >>> On Sun, Jun 29, 2008 at 12:48 PM, Sven Meier <sv...@meiers.net> wrote:
>> >>>> Hi,
>> >>>>
>> >>>> I've just converted two projects to the new generics setup and
>> everything
>> >>>> worked out nicely.
>> >>>> I think this is how generics should be applied to Wicket.
>> >>>>
>> >>>> Igor, thanks for your hard work on this.
>> >>>
>> >>> wasnt just me :)
>> >>>
>> >>> -igor
>> >>>
>> >>>>
>> >>>> Sven
>> >>>>
>> >>>> Igor Vaynberg schrieb:
>> >>>>>
>> >>>>> development of the 1.4 branch has been quiet lately, this is because
>> >>>>> the core team has been busy working on an alternative way of
>> >>>>> generifiing the framework. an early result of that effort can be
>> found
>> >>>>> here [1]. The key difference in [1] is that we have decoupled the
>> >>>>> component from the type of the model.
>> >>>>>
>> >>>>> here is the list of major differences:
>> >>>>>
>> >>>>> (1) only components that use their model have a generic type
>> >>>>> (components you are likely to call getmodel/getmodelobject on as a
>> >>>>> user). so far these are link,form,formcomponent
>> >>>>> subclasses,listview,listitem,(other repeaters will follow soon). this
>> >>>>> allows for typesafety where it makes sense, and eliminates a ton of
>> >>>>> noise from code. we will generify others upon request if a good
>> >>>>> usecase is provided and we think it is widely applicable.
>> >>>>>
>> >>>>> (2) non-generified components do not have IModel<T> get/setModel and
>> T
>> >>>>> get/setModelObject, instead they have IModel<?>get/setDefaultModel
>> and
>> >>>>> Object get/setDefaultModelObject. this clearly expresses that the
>> >>>>> default component model is not tied to the type of component. this is
>> >>>>> a bit of a pain from the code migration point of view, but we think
>> is
>> >>>>> worth the effort. generifyed components are free to implement the old
>> >>>>> IModel<T> get/setModel, etc, but have to keep the unsafe cast inside.
>> >>>>> see ListItem for an example.
>> >>>>>
>> >>>>> basically we feel this is a much cleaner way then what is 1.4m2. this
>> >>>>> is a call for confirmation/discussion from our user base. do try to
>> >>>>> port a small project or a part of a larger project you are working on
>> >>>>> to the [1] branch to see how the new api feels. if we do like this
>> >>>>> more the new branch will be merged into what will be 1.4m3.
>> >>>>>
>> >>>>> [1]
>> https://svn.apache.org/repos/asf/wicket/sandbox/ivaynberg/generics
>> >>>>>
>> >>>>> -igor
>> >>>>>
>> >>>>> ---------------------------------------------------------------------
>> >>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>>>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>
>> >>>>
>> >>>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>>
>> >>>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >>> For additional commands, e-mail: users-help@wicket.apache.org
>> >>>
>> >>>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Become a Wicket expert, learn from the best: http://wicketinaction.com
>> > Apache Wicket 1.3.4 is released
>> > Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Patrick Angeles <pa...@inertiabev.com>.
I second Matej here... maybe instead of GenericPanel<T>, GenericFragment<T>,
etc. you could name it something more explicit. Some examples:

SingleModelPanel<T>
ModelBoundPanel<T>

It took me the better part of one day to convert a partially genericized
project (we started out with 1.3 then switched to 1.4 mid-stream). The
project had 100k++ LOC. The resulting code is much easier to read.

Another thing that you can consider adding to the core... a utilities class
'Models' to wrap models so you don't have those pesky <> all over the place:

public MyPanel(String id, IModel<Integer> model)
{
   super (id, Models.compound (model)); // wrap model in a
CompoundPropertyModel
}




Matej Knopp-2 wrote:
> 
> There is one thing that helped me quite a lot when migration the
> project I'm working out. I've created GenericPanel,
> GenericWebMarkupContainer and GenericFragment classes. In most cases
> the only change was renaming Panel<MyClass> to GenericPanel<MyClass>.
> 
> I was wondering, even though those classes were farily simple, we
> might want to include them in Wicket anyway, for the sake of
> consistency and convenience.
> 
> -Matej
> 
> On Mon, Jun 30, 2008 at 12:28 PM, Johan Compagner <jc...@gmail.com>
> wrote:
>> i looked through the code and it is fine by me.
>> Lets test this then in a Build and see what people think of this.
>>
>>
>> On Mon, Jun 30, 2008 at 8:54 AM, Igor Vaynberg <ig...@gmail.com>
>> wrote:
>>
>>> unit tests are fixed...
>>>
>>> -igor
>>>
>>> On Sun, Jun 29, 2008 at 11:16 PM, Martijn Dashorst
>>> <ma...@gmail.com> wrote:
>>> > I'm guessing somewhere this week or so. We need to flush out the unit
>>> > test failures and get some preliminary feedback. Also we need to have
>>> > time available to actually build the release.
>>> >
>>> > My time is limited because we're in the final stages before publishing
>>> > and I have to read our book twice or so.
>>> >
>>> > Martijn
>>> >
>>> > On Mon, Jun 30, 2008 at 2:36 AM, James Carman
>>> > <ja...@carmanconsulting.com> wrote:
>>> >> What sort of time frame are we looking at for a release with this new
>>> >> generics paradigm?
>>> >>
>>> >> On Sun, Jun 29, 2008 at 3:54 PM, Igor Vaynberg
>>> <ig...@gmail.com>
>>> wrote:
>>> >>> On Sun, Jun 29, 2008 at 12:48 PM, Sven Meier <sv...@meiers.net>
>>> wrote:
>>> >>>> Hi,
>>> >>>>
>>> >>>> I've just converted two projects to the new generics setup and
>>> everything
>>> >>>> worked out nicely.
>>> >>>> I think this is how generics should be applied to Wicket.
>>> >>>>
>>> >>>> Igor, thanks for your hard work on this.
>>> >>>
>>> >>> wasnt just me :)
>>> >>>
>>> >>> -igor
>>> >>>
>>> >>>>
>>> >>>> Sven
>>> >>>>
>>> >>>> Igor Vaynberg schrieb:
>>> >>>>>
>>> >>>>> development of the 1.4 branch has been quiet lately, this is
>>> because
>>> >>>>> the core team has been busy working on an alternative way of
>>> >>>>> generifiing the framework. an early result of that effort can be
>>> found
>>> >>>>> here [1]. The key difference in [1] is that we have decoupled the
>>> >>>>> component from the type of the model.
>>> >>>>>
>>> >>>>> here is the list of major differences:
>>> >>>>>
>>> >>>>> (1) only components that use their model have a generic type
>>> >>>>> (components you are likely to call getmodel/getmodelobject on as a
>>> >>>>> user). so far these are link,form,formcomponent
>>> >>>>> subclasses,listview,listitem,(other repeaters will follow soon).
>>> this
>>> >>>>> allows for typesafety where it makes sense, and eliminates a ton
>>> of
>>> >>>>> noise from code. we will generify others upon request if a good
>>> >>>>> usecase is provided and we think it is widely applicable.
>>> >>>>>
>>> >>>>> (2) non-generified components do not have IModel<T> get/setModel
>>> and
>>> T
>>> >>>>> get/setModelObject, instead they have IModel<?>get/setDefaultModel
>>> and
>>> >>>>> Object get/setDefaultModelObject. this clearly expresses that the
>>> >>>>> default component model is not tied to the type of component. this
>>> is
>>> >>>>> a bit of a pain from the code migration point of view, but we
>>> think
>>> is
>>> >>>>> worth the effort. generifyed components are free to implement the
>>> old
>>> >>>>> IModel<T> get/setModel, etc, but have to keep the unsafe cast
>>> inside.
>>> >>>>> see ListItem for an example.
>>> >>>>>
>>> >>>>> basically we feel this is a much cleaner way then what is 1.4m2.
>>> this
>>> >>>>> is a call for confirmation/discussion from our user base. do try
>>> to
>>> >>>>> port a small project or a part of a larger project you are working
>>> on
>>> >>>>> to the [1] branch to see how the new api feels. if we do like this
>>> >>>>> more the new branch will be merged into what will be 1.4m3.
>>> >>>>>
>>> >>>>> [1]
>>> https://svn.apache.org/repos/asf/wicket/sandbox/ivaynberg/generics
>>> >>>>>
>>> >>>>> -igor
>>> >>>>>
>>> >>>>>
>>> ---------------------------------------------------------------------
>>> >>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>>>>
>>> >>>>>
>>> >>>>>
>>> >>>>
>>> >>>>
>>> >>>>
>>> ---------------------------------------------------------------------
>>> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>>>
>>> >>>>
>>> >>>
>>> >>>
>>> ---------------------------------------------------------------------
>>> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >>> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>>
>>> >>>
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> >> For additional commands, e-mail: users-help@wicket.apache.org
>>> >>
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Become a Wicket expert, learn from the best: http://wicketinaction.com
>>> > Apache Wicket 1.3.4 is released
>>> > Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> > For additional commands, e-mail: users-help@wicket.apache.org
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/generics-tp18083910p18222779.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Erik van Oosten <e....@grons.nl>.
In my current project I have:
10 Forms that use a CompoundPropertymodel and
5 Forms that have no model.

IMHO both Form forms :) should be easy to work with.

Regards,
    Erik.


Eelco Hillenius wrote:
>> thats my point. you work on fields of one object, true, but it does
>> not necessarily have to be the form's modelobject unless you use a
>> compound property model. eg
>>
>>        Form<Void> form = new Form<Void>("form")
>>        {
>>            protected void onSubmit() { value = dosomethingwith(symbol); }
>>        };
>>        add(form);
>>
>>        form.add(new TextField<String>("symbol", new
>> PropertyModel<String>(this, "symbol")));
>>
>> where [value] and [symbol] are clearly fields on the container that
>> parents the form. inside onsubmit i can just as easily access the
>> object directly without it being the model object of the form. now if
>> we factor out the form into a static inner or a top level class, just
>> like the link discussion, it becomes valuable to have the model.
>>     
>
> Yeah, you're right actually. I realize now that I rarely use Form's
> model directly. And I actually do the special stuff in the buttons
> anyway.
>
> Eelco
>
>
>   


--
Erik van Oosten
http://www.day-to-day-stuff.blogspot.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Eelco Hillenius <ee...@gmail.com>.
> thats my point. you work on fields of one object, true, but it does
> not necessarily have to be the form's modelobject unless you use a
> compound property model. eg
>
>        Form<Void> form = new Form<Void>("form")
>        {
>            protected void onSubmit() { value = dosomethingwith(symbol); }
>        };
>        add(form);
>
>        form.add(new TextField<String>("symbol", new
> PropertyModel<String>(this, "symbol")));
>
> where [value] and [symbol] are clearly fields on the container that
> parents the form. inside onsubmit i can just as easily access the
> object directly without it being the model object of the form. now if
> we factor out the form into a static inner or a top level class, just
> like the link discussion, it becomes valuable to have the model.

Yeah, you're right actually. I realize now that I rarely use Form's
model directly. And I actually do the special stuff in the buttons
anyway.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Eelco Hillenius <ee...@gmail.com>.
On Wed, Jul 2, 2008 at 12:53 PM, Sven Meier <sv...@meiers.net> wrote:
> Another thought:
> Why do we have a setter for the model actually?

Consider the case (that I sometimes have) where you want to set the
model in the component's constructor, but it needs a bit of
preparation first in such a way that you can't do it in the super or
this call.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Sven Meier <sv...@meiers.net>.
Another thought:
Why do we have a setter for the model actually?

I never call setDefaultModel() (formerly setModel()) in my code. In 
wicket-examples it seems that most calls to setDefaultModel() are done 
from inside the constructor (where it is sometimes needed because you 
cannot call instance methods before the super constructor call).

Shouldn't we declare this method (final) protected?
Custom components could just handle generified models in the 
constructor, the non-final getDefaultModel() could be overriden with the 
preferred return type (as already suggested).

And we could get rid of the 'default' in all this method names which 
frankly don't look too good to me.

Sven

Johan Compagner schrieb:
> thats completely up how you use it
> I can think of a lot that dont use models on FormComponents but only on
> Forms
> If you use CompoundModel then you never will touch or give a FormComponent a
> model.
> and all your stuff is done on the Model of the Form. (in the onSubmit for
> example)
>
> So this can never be generalized like this will never be used this way
> The only way for this is to have a complete separate stack of
> "ModelComponents/GenericComponents"
>
> See for example Link, Igor says i use model a lot. Eelco says he never uses
> it.. (but he uses it on button if i read correctly which is the same thing
> as a link)
>
> johan
>
>
> On Wed, Jul 2, 2008 at 9:15 AM, Jan Kriesten <ja...@renitence.de>
> wrote:
>
>   
>> Hi,
>>
>>  i agree that its no big deal, i am just trying to figure out some sort
>>     
>>> of guidelines for when we do include the type and when we dont. if we
>>> say that we only include the type when the component uses its model
>>> then neither Link nor Form qualify. in fact neither will ListItem.
>>> only things like ListView and FormComponents will qualify.
>>>
>>>       
>> I'd actually prefer untyped Link and Form, since I also don't use Models on
>> them directly most of the time. But other's may have a different style and
>> always use Models...
>>
>> Best regards, --- Jan.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Johan Compagner <jc...@gmail.com>.
thats completely up how you use it
I can think of a lot that dont use models on FormComponents but only on
Forms
If you use CompoundModel then you never will touch or give a FormComponent a
model.
and all your stuff is done on the Model of the Form. (in the onSubmit for
example)

So this can never be generalized like this will never be used this way
The only way for this is to have a complete separate stack of
"ModelComponents/GenericComponents"

See for example Link, Igor says i use model a lot. Eelco says he never uses
it.. (but he uses it on button if i read correctly which is the same thing
as a link)

johan


On Wed, Jul 2, 2008 at 9:15 AM, Jan Kriesten <ja...@renitence.de>
wrote:

>
> Hi,
>
>  i agree that its no big deal, i am just trying to figure out some sort
>> of guidelines for when we do include the type and when we dont. if we
>> say that we only include the type when the component uses its model
>> then neither Link nor Form qualify. in fact neither will ListItem.
>> only things like ListView and FormComponents will qualify.
>>
>
> I'd actually prefer untyped Link and Form, since I also don't use Models on
> them directly most of the time. But other's may have a different style and
> always use Models...
>
> Best regards, --- Jan.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: generics

Posted by Jan Kriesten <ja...@renitence.de>.
Hi,

> i agree that its no big deal, i am just trying to figure out some sort
> of guidelines for when we do include the type and when we dont. if we
> say that we only include the type when the component uses its model
> then neither Link nor Form qualify. in fact neither will ListItem.
> only things like ListView and FormComponents will qualify.

I'd actually prefer untyped Link and Form, since I also don't use Models on them 
directly most of the time. But other's may have a different style and always use 
Models...

Best regards, --- Jan.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Roland Huss <na...@tichny.org>.
But at the end, I want my model object back to do some business with it, so I
could either store the CPM myself for later reference (but why would I want
to do this ?) or retrieve it from the Form's model (typesafe, if possible).
That's why a generified Form would be nice.

... roland


svenmeier wrote:
> 
> Just because you're using a CompoundPropertyModel on your Forms doesn't 
> mean you need it generified.
> 
> Sven
> 
> Roland Huss schrieb:
>>
>> igor.vaynberg wrote:
>>   
>>> On Tue, Jul 1, 2008 at 11:28 PM, Eelco Hillenius
>>> <ee...@gmail.com> wrote:
>>> thats my point. you work on fields of one object, true, but it does
>>> not necessarily have to be the form's modelobject unless you use a
>>> compound property model. 
>>>
>>>     
>>
>> The usage of a CompoundPropertyModel as a Form-model saved us quite some
>> typing and it's IMO 
>> a very common use case. In fact, this it propbably the most relevant use
>> case for a CPM anyway.
>> So, I'm in favor of having a Form with Model (or at least a variation
>> like a
>> ModelForm<T> ...)
>>
>> ... roland
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/generics-tp18083910p18245100.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Sven Meier <sv...@meiers.net>.
Just because you're using a CompoundPropertyModel on your Forms doesn't 
mean you need it generified.

Sven

Roland Huss schrieb:
>
> igor.vaynberg wrote:
>   
>> On Tue, Jul 1, 2008 at 11:28 PM, Eelco Hillenius
>> <ee...@gmail.com> wrote:
>> thats my point. you work on fields of one object, true, but it does
>> not necessarily have to be the form's modelobject unless you use a
>> compound property model. 
>>
>>     
>
> The usage of a CompoundPropertyModel as a Form-model saved us quite some
> typing and it's IMO 
> a very common use case. In fact, this it propbably the most relevant use
> case for a CPM anyway.
> So, I'm in favor of having a Form with Model (or at least a variation like a
> ModelForm<T> ...)
>
> ... roland
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Roland Huss <na...@tichny.org>.


igor.vaynberg wrote:
> 
> On Tue, Jul 1, 2008 at 11:28 PM, Eelco Hillenius
> <ee...@gmail.com> wrote:
> thats my point. you work on fields of one object, true, but it does
> not necessarily have to be the form's modelobject unless you use a
> compound property model. 
> 

The usage of a CompoundPropertyModel as a Form-model saved us quite some
typing and it's IMO 
a very common use case. In fact, this it propbably the most relevant use
case for a CPM anyway.
So, I'm in favor of having a Form with Model (or at least a variation like a
ModelForm<T> ...)

... roland
-- 
View this message in context: http://www.nabble.com/generics-tp18083910p18231920.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Igor Vaynberg <ig...@gmail.com>.
On Tue, Jul 1, 2008 at 11:28 PM, Eelco Hillenius
<ee...@gmail.com> wrote:
> On Tue, Jul 1, 2008 at 11:09 PM, Igor Vaynberg <ig...@gmail.com> wrote:
>> if we ungenerify Link, should we also ungenerify Form? seems like the
>> exact same kind of usecase.
>
> Imho, generic forms make more sense, as you'd typically work on fields
> (with formcomponents) of one object (the model object of the form)

thats my point. you work on fields of one object, true, but it does
not necessarily have to be the form's modelobject unless you use a
compound property model. eg

        Form<Void> form = new Form<Void>("form")
        {
            protected void onSubmit() { value = dosomethingwith(symbol); }
        };
        add(form);

        form.add(new TextField<String>("symbol", new
PropertyModel<String>(this, "symbol")));

where [value] and [symbol] are clearly fields on the container that
parents the form. inside onsubmit i can just as easily access the
object directly without it being the model object of the form. now if
we factor out the form into a static inner or a top level class, just
like the link discussion, it becomes valuable to have the model.

> Anyway, not a big deal really. If you feel Link is better generified,
> I'm cool with it.

i agree that its no big deal, i am just trying to figure out some sort
of guidelines for when we do include the type and when we dont. if we
say that we only include the type when the component uses its model
then neither Link nor Form qualify. in fact neither will ListItem.
only things like ListView and FormComponents will qualify.

-igor

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Eelco Hillenius <ee...@gmail.com>.
On Tue, Jul 1, 2008 at 11:09 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> if we ungenerify Link, should we also ungenerify Form? seems like the
> exact same kind of usecase.

Imho, generic forms make more sense, as you'd typically work on fields
(with formcomponents) of one object (the model object of the form),
and then do something with it if updating the fields succeeds (like
saving the changes). It is true that you often use some model value(s)
in the link onClick method, but personally I never do that through the
model value, but rather like how Timo described it.

Anyway, not a big deal really. If you feel Link is better generified,
I'm cool with it.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Igor Vaynberg <ig...@gmail.com>.
if we ungenerify Link, should we also ungenerify Form? seems like the
exact same kind of usecase.

-igor

On Tue, Jul 1, 2008 at 10:25 PM, Eelco Hillenius
<ee...@gmail.com> wrote:
>> This is not a big deal though, either way is fine by me.
>
> I prefer link to be not generified, but either way is fine by me as well.
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Eelco Hillenius <ee...@gmail.com>.
> This is not a big deal though, either way is fine by me.

I prefer link to be not generified, but either way is fine by me as well.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Eelco Hillenius <ee...@gmail.com>.
On Thu, Jul 3, 2008 at 9:46 AM, Eelco Hillenius
<ee...@gmail.com> wrote:
>>> On Thu, Jul 3, 2008 at 12:47 AM, Matej Knopp <ma...@gmail.com> wrote:
>>>> Ligther? Does it meen with no Compund and ComponentAssignedModel?
>>>> Wouldn't that feel more like crippled?
>>>> The default model slot doesn't take any runtime space when you don't
>>>> use it, property would. And removing four methods from component will
>>>> hardly make it much lighter.
>>>
>> Big +1 on that :)
>
> That's a +1 on your own reply... cheater! ;-)

Like Martijn said.... ugh I need to learn to read the rest of the
thread before replying first!

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matej Knopp <ma...@gmail.com>.
On Thu, Jul 3, 2008 at 10:02 AM, Eelco Hillenius
<ee...@gmail.com> wrote:
> On Thu, Jul 3, 2008 at 12:47 AM, Matej Knopp <ma...@gmail.com> wrote:
>> Ligther? Does it meen with no Compund and ComponentAssignedModel?
>> Wouldn't that feel more like crippled?
>> The default model slot doesn't take any runtime space when you don't
>> use it, property would. And removing four methods from component will
>> hardly make it much lighter.
>
> I wasn't just thinking about models though. *I* would like us to go
> through the API when we start on 1.5 and remove anything that isn't
> necessary. Remove all the the deprecations and convenience methods
> that have (easy) alternatives. All the while keeping an easy upgrade
> path in mind of course.
Okay. Big +1 here of course.,

-Matej

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Eelco Hillenius <ee...@gmail.com>.
>> On Thu, Jul 3, 2008 at 12:47 AM, Matej Knopp <ma...@gmail.com> wrote:
>>> Ligther? Does it meen with no Compund and ComponentAssignedModel?
>>> Wouldn't that feel more like crippled?
>>> The default model slot doesn't take any runtime space when you don't
>>> use it, property would. And removing four methods from component will
>>> hardly make it much lighter.
>>
> Big +1 on that :)

That's a +1 on your own reply... cheater! ;-)

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matej Knopp <ma...@gmail.com>.
Rofl :) I've slept like 4 hours. I wanted to +1 Eelco of course. Or
maybe that just my Ego and my subconciousness messing with me.

On Thu, Jul 3, 2008 at 10:22 AM, Martijn Dashorst
<ma...@gmail.com> wrote:
> Matej: drink some coffee, you're +1-ing yourself now :)
>
> Martijn
>
> On Thu, Jul 3, 2008 at 10:08 AM, Matej Knopp <ma...@gmail.com> wrote:
>> On Thu, Jul 3, 2008 at 10:02 AM, Eelco Hillenius
>> <ee...@gmail.com> wrote:
>>> On Thu, Jul 3, 2008 at 12:47 AM, Matej Knopp <ma...@gmail.com> wrote:
>>>> Ligther? Does it meen with no Compund and ComponentAssignedModel?
>>>> Wouldn't that feel more like crippled?
>>>> The default model slot doesn't take any runtime space when you don't
>>>> use it, property would. And removing four methods from component will
>>>> hardly make it much lighter.
>>>
>> Big +1 on that :)
>
> --
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.3.4 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Martijn Dashorst <ma...@gmail.com>.
Matej: drink some coffee, you're +1-ing yourself now :)

Martijn

On Thu, Jul 3, 2008 at 10:08 AM, Matej Knopp <ma...@gmail.com> wrote:
> On Thu, Jul 3, 2008 at 10:02 AM, Eelco Hillenius
> <ee...@gmail.com> wrote:
>> On Thu, Jul 3, 2008 at 12:47 AM, Matej Knopp <ma...@gmail.com> wrote:
>>> Ligther? Does it meen with no Compund and ComponentAssignedModel?
>>> Wouldn't that feel more like crippled?
>>> The default model slot doesn't take any runtime space when you don't
>>> use it, property would. And removing four methods from component will
>>> hardly make it much lighter.
>>
> Big +1 on that :)

-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matej Knopp <ma...@gmail.com>.
On Thu, Jul 3, 2008 at 10:02 AM, Eelco Hillenius
<ee...@gmail.com> wrote:
> On Thu, Jul 3, 2008 at 12:47 AM, Matej Knopp <ma...@gmail.com> wrote:
>> Ligther? Does it meen with no Compund and ComponentAssignedModel?
>> Wouldn't that feel more like crippled?
>> The default model slot doesn't take any runtime space when you don't
>> use it, property would. And removing four methods from component will
>> hardly make it much lighter.
>
Big +1 on that :)

> I wasn't just thinking about models though. *I* would like us to go
> through the API when we start on 1.5 and remove anything that isn't
> necessary. Remove all the the deprecations and convenience methods
> that have (easy) alternatives. All the while keeping an easy upgrade
> path in mind of course.
>
> Of course, things like compound property models are pretty cool, and
> we should keep supporting the types of models we are supporting now.
> But maybe we can find a way to add this kind of support to components
> without needing it to be built in. Or maybe not and in the end our
> conclusion will be to stick with 1.4's model. But lets try to be
> creative before we give up on that :-)

Creative is ok for me. Destructive isn't :)
>
> We're getting a bit ahead of ourselves now though, unless we already
> want to start coding on 1.5. It is probably a better idea to finalize
> 1.4 first, and decide on what to generify by default based on the
> likeliness it will help users for this version.

Yeah, agree on this as well.

-Matej
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Eelco Hillenius <ee...@gmail.com>.
On Thu, Jul 3, 2008 at 12:47 AM, Matej Knopp <ma...@gmail.com> wrote:
> Ligther? Does it meen with no Compund and ComponentAssignedModel?
> Wouldn't that feel more like crippled?
> The default model slot doesn't take any runtime space when you don't
> use it, property would. And removing four methods from component will
> hardly make it much lighter.

I wasn't just thinking about models though. *I* would like us to go
through the API when we start on 1.5 and remove anything that isn't
necessary. Remove all the the deprecations and convenience methods
that have (easy) alternatives. All the while keeping an easy upgrade
path in mind of course.

Of course, things like compound property models are pretty cool, and
we should keep supporting the types of models we are supporting now.
But maybe we can find a way to add this kind of support to components
without needing it to be built in. Or maybe not and in the end our
conclusion will be to stick with 1.4's model. But lets try to be
creative before we give up on that :-)

We're getting a bit ahead of ourselves now though, unless we already
want to start coding on 1.5. It is probably a better idea to finalize
1.4 first, and decide on what to generify by default based on the
likeliness it will help users for this version.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matej Knopp <ma...@gmail.com>.
Ligther? Does it meen with no Compund and ComponentAssignedModel?
Wouldn't that feel more like crippled?
The default model slot doesn't take any runtime space when you don't
use it, property would. And removing four methods from component will
hardly make it much lighter.

-Matej

On Thu, Jul 3, 2008 at 7:13 AM, Eelco Hillenius
<ee...@gmail.com> wrote:
>> What I mean is that post-1.4 it would be good to remove the
>> defaultModel* stuff and other IModel dependencies from
>> Component, and maybe try to move towards a more case-by-case
>> model handling in generified (actually
>> typed-after-their-default-model-type) components as well.
>
> I'm very much in favor of that. If it were up to me, I would actually
> try to cut away from component (and other pivotal classes for that
> matter) as much as possible. I'd love Wicket to feel lighter and more
> pointed with 1.5 rather than heavy with convenience like it is now.
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Eelco Hillenius <ee...@gmail.com>.
> What I mean is that post-1.4 it would be good to remove the
> defaultModel* stuff and other IModel dependencies from
> Component, and maybe try to move towards a more case-by-case
> model handling in generified (actually
> typed-after-their-default-model-type) components as well.

I'm very much in favor of that. If it were up to me, I would actually
try to cut away from component (and other pivotal classes for that
matter) as much as possible. I'd love Wicket to feel lighter and more
pointed with 1.5 rather than heavy with convenience like it is now.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Wed, 02 Jul 2008, Johan Compagner wrote:
> I still dont see a complete decoupling or do you mean only getDefaultXxxx()?

What I mean is that post-1.4 it would be good to remove the
defaultModel* stuff and other IModel dependencies from
Component, and maybe try to move towards a more case-by-case
model handling in generified (actually
typed-after-their-default-model-type) components as well.

> So all the getModel() (Link/FormComponent) are still there?

I wouldn't mind trying to see if we could remove the magic
currently done in get/setModel* in those too, and if model
becomes a normal field in those (instead of an element
stored in Component.data), open it to subclasses by making
it protected and leave implementing a part of those methods
to the users. Often it's better for the design to avoid
using getters and setters.

Some of the magic might work in the models themselves, for
example making the component aware models... aware of the
relevant components :)

This might turn out not to be practical, and either way
having the get/setModel* by default in the generified
components is fine by me -- just thinking about different
options, and whether they have relevance on what will go to
1.4.

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Johan Compagner <jc...@gmail.com>.
I still dont see a complete decoupling or do you mean only getDefaultXxxx()?
So all the getModel() (Link/FormComponent) are still there?

For link we could have Link (without model) and ModelLink (generified
and with get/setModel) that would be fine with me.

On 7/2/08, Timo Rantalaiho <Ti...@ri.fi> wrote:
> On Tue, 01 Jul 2008, Matej Knopp wrote:
>> There is one thing that helped me quite a lot when migration the
>> project I'm working out. I've created GenericPanel,
>> GenericWebMarkupContainer and GenericFragment classes. In most cases
>> the only change was renaming Panel<MyClass> to GenericPanel<MyClass>.
>
> Maybe the names could be TypedPanel / ModelContainingPanel
> or something like that?
>
> Or maybe start with the original component name so that they
> would pop up more easily in the IDE, for example
> PanelWithType / PanelWithModel?
>
>> I was wondering, even though those classes were farily simple, we
>> might want to include them in Wicket anyway, for the sake of
>> consistency and convenience.
>
> I thought about this and I think that it might be better to
> not include them after all. In 1.5 it would be great to
> separate IModel and Component more thoroughly, getting rid
> of the defaultModel* accessors. Then it would make less
> sense to have the convenience classes with those model and
> modelObject accessors.
>
> In cases where two components share the same model, it would
> make sense to make the IModel field in each component final.
> Then setModel() does not make sense any more; all it could
> do would be throw an exception or be a confusing no-op.
> Likewise, sometimes you never do setModelObject() or
> getModelObject() from outside the class.
>
> Leaner APIs and less methods per objects are good things.
> Hence it's better to add methods as you need them, instead
> of providing a lot of convenience stuff that is only used a
> part of the time. Surely each Component subclass has anyway
> a lot of methods, and MarkupContainers even more, but you
> have got to start somewhere :)
>
> This is not a big deal though, either way is fine by me.
>
> Best wishes,
> Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Thu, 03 Jul 2008, Matej Knopp wrote:
> I'm gonna be -1 on removing model utility methods and default model
> slot from component until you suggest a clean and transparent way to
> support
> - compound (inherited) models
> - component assigned models
> - automatic detachment

Fair enough, let's see what we can come up with :)

I was thinking that most of that stuff could be achieved by
moving more logic to the model classes. Some things such as
the add(new Label("name")); for
CompoundPropertyModel-component children could be tricky to
get working though.

Anyway, I agree that now our focus must be on getting 1.4
out of the door -- the reason this came up was just that I
was thinking out loud whether the plans for 1.5 have
implications on what to add in 1.4.

Automatic detachment for all IModel fields of a component
would be great (and the easiest to do of those I suppose).

> From component where? ComponentUtil? Component has a very strong and
> complicated contract. There are lot of methods in component, but there
> are reasons for it. There are parts like rendering though that might
> need to be cleaned up.

Definitely not to a utility class with static methods :)
Maybe some of the responsibilities can be moved to different
other classes, such as ComponentTag and MarkupStream. But
let's see that when working on 1.5.

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Maarten Bosteels <mb...@gmail.com>.
Haven't yet tried it myself, but this project seems like a big help when you
have to support ProperyChangeListener etc :

https://bean-properties.dev.java.net/10things.html

Maarten

On Tue, Jul 8, 2008 at 2:03 PM, David N. Arnold <da...@gmail.com>
wrote:

> See this article
>
> http://weblogs.java.net/blog/rbair/archive/2006/05/the_unknown_jav.html
>
> for a clean solution to this problem.  Essentially, you can grab a
> class "JavaBean" from the SwingX project and extend it.
>
> Of course if you're already extending another class it doesn't really
> help you out...
>
>
> On Tue, Jul 8, 2008 at 5:58 AM, Matthijs Wensveen <m....@func.nl>
> wrote:
> > I always find using PropertyChangeSupport and ProperyChangeListener is a
> lot
> > of work and kinda pollutes your code. But it is a solution. Maybe a
> > combination of ProperyChangeListener and AOP could be made to reduce the
> > required boilerplate code.
> >
> > Matthijs
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: generics

Posted by "David N. Arnold" <da...@gmail.com>.
See this article

http://weblogs.java.net/blog/rbair/archive/2006/05/the_unknown_jav.html

for a clean solution to this problem.  Essentially, you can grab a
class "JavaBean" from the SwingX project and extend it.

Of course if you're already extending another class it doesn't really
help you out...


On Tue, Jul 8, 2008 at 5:58 AM, Matthijs Wensveen <m....@func.nl> wrote:
> I always find using PropertyChangeSupport and ProperyChangeListener is a lot
> of work and kinda pollutes your code. But it is a solution. Maybe a
> combination of ProperyChangeListener and AOP could be made to reduce the
> required boilerplate code.
>
> Matthijs
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matthijs Wensveen <m....@func.nl>.
I always find using PropertyChangeSupport and ProperyChangeListener is a 
lot of work and kinda pollutes your code. But it is a solution. Maybe a 
combination of ProperyChangeListener and AOP could be made to reduce the 
required boilerplate code.

Matthijs

Johan Compagner wrote:
> thats just a listener interface for example PropertyChangeListener (but you
> can make it more specific interface)
> Just make a base model that has add/removePropertyChangeListener and let
> your components listen to that
>
> johan
>
>
> On Mon, Jul 7, 2008 at 8:28 AM, Matthijs Wensveen <m....@func.nl>
> wrote:
>
>   
>> Timo Rantalaiho wrote:
>>
>>     
>>> On Fri, 04 Jul 2008, Matthijs Wensveen wrote:
>>>
>>>
>>>       
>>>> How do you cope with deeply nested model properties? For example:
>>>>
>>>> public class PersonViewer extends Component<Person> {
>>>> ..
>>>> }
>>>>
>>>> some other component does:
>>>> person.getOrders().get(0).setAmount(0); // first order for free (as in
>>>> beer)
>>>>
>>>>
>>>>         
>>> I have no idea of Johan's project, but normally you just edit an object in
>>> one place at a time, and PersonViewer would be a read-only component with a
>>> model that always pulls the freshest version of the person it is displaying
>>> from the database.
>>>
>>> Best wishes,
>>> Timo
>>>
>>>
>>>
>>>       
>> The thing is that when using Ajax you have to specifically add PersonViewer
>> to the AjaxRequestTarget when 'some other component' modifies the Person
>> object. The problem is that 'some other component' might not even know about
>> or have access to PersonViewer (maybe it's a 3rd-party component).
>> OnModelChanged does not work in this case, because there is no call to
>> setModelObject, just to some setter of the Person object.
>>
>> While Ajax does very nice things to the GUI, it kinda messes up the
>> model-driven (as in wicket model) approach to gui development. That is why I
>> was thinking about some aspect-oriented solution to let components know
>> about model updates, even when they keep a reference to the same object.
>>
>> Matthijs
>>
>> --
>> Matthijs Wensveen
>> Func. Internet Integration
>> W http://www.func.nl
>> T +31 20 4230000
>> F +31 20 4223500
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
>   


-- 
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Johan Compagner <jc...@gmail.com>.
thats just a listener interface for example PropertyChangeListener (but you
can make it more specific interface)
Just make a base model that has add/removePropertyChangeListener and let
your components listen to that

johan


On Mon, Jul 7, 2008 at 8:28 AM, Matthijs Wensveen <m....@func.nl>
wrote:

> Timo Rantalaiho wrote:
>
>> On Fri, 04 Jul 2008, Matthijs Wensveen wrote:
>>
>>
>>> How do you cope with deeply nested model properties? For example:
>>>
>>> public class PersonViewer extends Component<Person> {
>>> ..
>>> }
>>>
>>> some other component does:
>>> person.getOrders().get(0).setAmount(0); // first order for free (as in
>>> beer)
>>>
>>>
>>
>> I have no idea of Johan's project, but normally you just edit an object in
>> one place at a time, and PersonViewer would be a read-only component with a
>> model that always pulls the freshest version of the person it is displaying
>> from the database.
>>
>> Best wishes,
>> Timo
>>
>>
>>
> The thing is that when using Ajax you have to specifically add PersonViewer
> to the AjaxRequestTarget when 'some other component' modifies the Person
> object. The problem is that 'some other component' might not even know about
> or have access to PersonViewer (maybe it's a 3rd-party component).
> OnModelChanged does not work in this case, because there is no call to
> setModelObject, just to some setter of the Person object.
>
> While Ajax does very nice things to the GUI, it kinda messes up the
> model-driven (as in wicket model) approach to gui development. That is why I
> was thinking about some aspect-oriented solution to let components know
> about model updates, even when they keep a reference to the same object.
>
> Matthijs
>
> --
> Matthijs Wensveen
> Func. Internet Integration
> W http://www.func.nl
> T +31 20 4230000
> F +31 20 4223500
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: generics

Posted by Matthijs Wensveen <m....@func.nl>.
Timo Rantalaiho wrote:
> On Mon, 07 Jul 2008, Matthijs Wensveen wrote:
>   
>> The thing is that when using Ajax you have to specifically add 
>> PersonViewer to the AjaxRequestTarget when 'some other component' 
>> modifies the Person object. The problem is that 'some other component' 
>> might not even know about or have access to PersonViewer (maybe it's a 
>> 3rd-party component). OnModelChanged does not work in this case, because 
>> there is no call to setModelObject, just to some setter of the Person 
>> object.
>>     
>
> Yep, in our current project we use the WICKET-1312
> "broadcaster" approach to solve this. This means that the
> logic of which component needs to be repainted when
> something happens is in the UI components. (The domain logic
> itself we try to put in the domain objects.) 
>
> So in our model, the other component modifying the Person
> object would broadcast a PersonModifiedEvent to all
> PersonModificationReceiver components, who could then act
> accordingly (typically add themselves to the Ajax request
> target). There's not a lot of automagical intelligence
> there, but we have found this way clear and effective. All
> relationships are "static" on component class level and
> navigable in the IDE. The proliferation of events and
> receivers must be watched out for though.
>   

I knew about WICKET-1312, but hadn't thought of broadcasting domain 
object typed events, just things like onClick and such which gives too 
little information. Thanks for the eyeopener!

>   
>> While Ajax does very nice things to the GUI, it kinda messes up the 
>> model-driven (as in wicket model) approach to gui development. That is 
>> why I was thinking about some aspect-oriented solution to let components 
>> know about model updates, even when they keep a reference to the same 
>> object.
>>     
>
> That's true. It's a pity that for now, Java AOP solutions
> are still a bit invasive (AFAIK, if you know of some really
> neat and transparent implementation without -javaagents or
> special compilers or some such nuisance, I'd be glad to hear
> :)). 
>
> We tried sharing models and making them more intelligent and
> models sending events to registered listeners and whatnot
> dead chickens before arriving at the current
> broadcast/receiver approach. When the components are
> "physically" far away from each other, sharing the model or
> handling registration and deregistration can get hairy. And
> to avoid memory leaks, removing the listeners when
> components are being replaced (e.g. repeater children
> recreated) should be taken care of carefully in a
> traditional event-listener mechanism.
>   

Maybe listeners could be registered using weak references so that the 
objects are still garbage collected even when the listener is still alive.
> However, more experimentation is definitely needed on this,
> and I'd be very interested on hearing any experiences and
> ideas!  It seems that ajax will be around for some more
> years, whether we like it or not, so best to make the best
> out of it :)
>
> Best wishes, Timo
>   

Matthijs

-- 
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Mon, 07 Jul 2008, Matthijs Wensveen wrote:
> The thing is that when using Ajax you have to specifically add 
> PersonViewer to the AjaxRequestTarget when 'some other component' 
> modifies the Person object. The problem is that 'some other component' 
> might not even know about or have access to PersonViewer (maybe it's a 
> 3rd-party component). OnModelChanged does not work in this case, because 
> there is no call to setModelObject, just to some setter of the Person 
> object.

Yep, in our current project we use the WICKET-1312
"broadcaster" approach to solve this. This means that the
logic of which component needs to be repainted when
something happens is in the UI components. (The domain logic
itself we try to put in the domain objects.) 

So in our model, the other component modifying the Person
object would broadcast a PersonModifiedEvent to all
PersonModificationReceiver components, who could then act
accordingly (typically add themselves to the Ajax request
target). There's not a lot of automagical intelligence
there, but we have found this way clear and effective. All
relationships are "static" on component class level and
navigable in the IDE. The proliferation of events and
receivers must be watched out for though.

> While Ajax does very nice things to the GUI, it kinda messes up the 
> model-driven (as in wicket model) approach to gui development. That is 
> why I was thinking about some aspect-oriented solution to let components 
> know about model updates, even when they keep a reference to the same 
> object.

That's true. It's a pity that for now, Java AOP solutions
are still a bit invasive (AFAIK, if you know of some really
neat and transparent implementation without -javaagents or
special compilers or some such nuisance, I'd be glad to hear
:)). 

We tried sharing models and making them more intelligent and
models sending events to registered listeners and whatnot
dead chickens before arriving at the current
broadcast/receiver approach. When the components are
"physically" far away from each other, sharing the model or
handling registration and deregistration can get hairy. And
to avoid memory leaks, removing the listeners when
components are being replaced (e.g. repeater children
recreated) should be taken care of carefully in a
traditional event-listener mechanism.

However, more experimentation is definitely needed on this,
and I'd be very interested on hearing any experiences and
ideas!  It seems that ajax will be around for some more
years, whether we like it or not, so best to make the best
out of it :)

Best wishes, Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matthijs Wensveen <m....@func.nl>.
Timo Rantalaiho wrote:
> On Fri, 04 Jul 2008, Matthijs Wensveen wrote:
>   
>> How do you cope with deeply nested model properties? For example:
>>
>> public class PersonViewer extends Component<Person> {
>> ..
>> }
>>
>> some other component does:
>> person.getOrders().get(0).setAmount(0); // first order for free (as in beer)
>>     
>
> I have no idea of Johan's project, but normally you just 
> edit an object in one place at a time, and PersonViewer 
> would be a read-only component with a model that always 
> pulls the freshest version of the person it is displaying 
> from the database.
>
> Best wishes,
> Timo
>
>   
The thing is that when using Ajax you have to specifically add 
PersonViewer to the AjaxRequestTarget when 'some other component' 
modifies the Person object. The problem is that 'some other component' 
might not even know about or have access to PersonViewer (maybe it's a 
3rd-party component). OnModelChanged does not work in this case, because 
there is no call to setModelObject, just to some setter of the Person 
object.

While Ajax does very nice things to the GUI, it kinda messes up the 
model-driven (as in wicket model) approach to gui development. That is 
why I was thinking about some aspect-oriented solution to let components 
know about model updates, even when they keep a reference to the same 
object.

Matthijs

-- 
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Fri, 04 Jul 2008, Matthijs Wensveen wrote:
> How do you cope with deeply nested model properties? For example:
> 
> public class PersonViewer extends Component<Person> {
> ..
> }
> 
> some other component does:
> person.getOrders().get(0).setAmount(0); // first order for free (as in beer)

I have no idea of Johan's project, but normally you just 
edit an object in one place at a time, and PersonViewer 
would be a read-only component with a model that always 
pulls the freshest version of the person it is displaying 
from the database.

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matej Knopp <ma...@gmail.com>.
Okay, long story short.

I'm gonna be -1 on removing model utility methods and default model
slot from component until you suggest a clean and transparent way to
support
- compound (inherited) models
- component assigned models
- automatic detachment

Just because you don't use these features it doesn't mean there are
not users who do.
There is convenience, removing bloat and just crippling the API. And
there's difference between these.

Don't take me wrong, I don't mind removing the *default* methods from
components, but not in a way that is going to sacrifice any of the
mentioned functionality.

On Thu, Jul 3, 2008 at 5:32 AM, Timo Rantalaiho <Ti...@ri.fi> wrote:
> On Wed, 02 Jul 2008, Matej Knopp wrote:
>> I still don't see what's wrong with GenericPanel. It's certainly much
>> easier to type than ModelContainingPanel.
>
> Nothing wrong with that either, it's just very generic :)
>
> There are a lot of ways of making use of generics in a
> component besides just adding the type parameter bound to
> the type parameter of the model of the component.
>
> I mean, if you have
>
> public FooPanel extends GenericPanel<Foo> {
>    public FooPanel(String id, IModel<Foo> model, IModel<List<Bar>> bars) {
>    ...
>    }
> ...
> }
>
> it's not so much more generic than
>
> public FooPanel extends Panel {
>    public FooPanel(String id, IModel<Foo> model, IModel<List<Bar>> bars) {
>    ...
>    }
> ...
> }
>
>> I strongly disagree. There are good reasons for Wicket to bind model
>> and component together and I think what we have in 1.4 right now is a
>> balanced compromise.
>
> I'd be glad to hear more on this! For now, I imagine that a
> lot of stuff that the Component IModel dependency exists for
> could be done in other ways.

Sure, mind sharing how?

>
> And there is some functionality in there that Wicket might
> be better without. For example, onModelChanged / Changing
> things become tricky when you share the same model between
> different instances. And when using setModelObject() with an
> object that is equal to the current model object, but a
> different instance (such as a Hibernate-persisted object
> bound to the correct session), you have to either do
> getModel().setObject() or change the model comparator.
>
> Again, I'm just exploring, and perhaps overlooking
> something.
>
>> Also if we don't provide the convenience classes
>> people will bound to write their own (because it's the only reasonable
>> way to migrate project that already uses generics).
>
> That's true, I just thought it would be no big deal and only
> affect the earliest 1.4 adopters (or those still converting
> from 2.0 if there are any left) (sorry :)). I had in mind
> that if we then remove those convenience classes in 1.5,
> they would have to move to the user codebases anyway, but
> maybe 1.4 -> 1.5 will not be such a common migration path
> because of API breaks.
>
>> I don't buy this. Our components have a lot of methods, but most of
>> them are not part of public API. I plan to prefix those methods with a
>> common prefix for 1.5 so they don't confuse regular users. But I
>> really don't see how removing four methods (*defaultModel) improves
>> our api.
>
> It would be better (altough harder) to move responsibilities
> away from Component to other classes, which could be then
> marked as not being a part of the public API. When you do
> the rename I'll be happy to do a spike of moving some of the
> renamed stuff away from Component altogether :)

>From component where? ComponentUtil? Component has a very strong and
complicated contract. There are lot of methods in component, but there
are reasons for it. There are parts like rendering though that might
need to be cleaned up.

>
>> Models have always been conceptually bound to component. Right now the
>> problem of our API is not that we have a model slot in component. It
>> is that we have exactly one model slot. This doesn't work well for all
>> components, since some don't need model at all and some need more than
>> one.
>
> Yeah, if we cannot get rid of the default model handling
> (which I still hope to be possible), at least a more
> flexible abstraction (IModelsContainer?) might be good.
>
>> esier. Now thinking about it, the name should really suggest that
>> there is one model per component. Maybe PanelWithModel could be the
>> name after all :)
>
> PanelWithExactlyOneModelInTheDefaultSlotAndHoldingAnObjectOfTheSameTypeAsTheTypeParameterOfThisComponent :)
>
> Best wishes,
> Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matthijs Wensveen <m....@func.nl>.
How do you cope with deeply nested model properties? For example:

public class PersonViewer extends Component<Person> {
..
}

some other component does:
person.getOrders().get(0).setAmount(0); // first order for free (as in beer)

Matthijs

Johan Compagner wrote:
> There are many state things in a component. Wicket itself has only a
> few like model/visibile/enable. But a developer could add many many
> more.
>
> In our project this is easily handled by our components. Every
> component knows when it is changed, what ever it is and then a visitor
> adds them to ajax. We have a fixed set of components so its not a big
> problem.
>
> On 7/4/08, Matthijs Wensveen <m....@func.nl> wrote:
>   
>> Matej Knopp wrote:
>>     
>>> On Thu, Jul 3, 2008 at 9:51 AM, Matej Knopp <ma...@gmail.com> wrote:
>>>
>>>       
>>>>> And there is some functionality in there that Wicket might
>>>>> be better without. For example, onModelChanged / Changing
>>>>> things become tricky when you share the same model between
>>>>> different instances. And when using setModelObject() with an
>>>>> object that is equal to the current model object, but a
>>>>> different instance (such as a Hibernate-persisted object
>>>>> bound to the correct session), you have to either do
>>>>> getModel().setObject() or change the model comparator.
>>>>>
>>>>>
>>>>>           
>>>> setModelObject isn't the best idea IMHO. Models should support some
>>>> kind of state change notifications, we might want to improve that for
>>>> 1.5, though it probably wouldn't be very easy to do.
>>>>
>>>>         
>>> Well, we can hardly detect change of propertypromodels unless we pull
>>> and compare the value every time...
>>>
>>>       
>> Better state change notifications would be a huge improvement IMO
>> because that way components could add themselves to AjaxRequestTarget
>> when needed. Currently all Ajax functionality requires Ajaxified
>> components to know about each other and when they should be displayed.
>> Some kind of even mechanism as described in
>> https://issues.apache.org/jira/browse/WICKET-1312 would definitely help,
>> but a model-driven approach would be even better.
>>
>> I was thinking to support this using annotations and aspects and the
>> likes, but I haven't had the time to create a proof of concept.
>>
>> Matthijs
>>
>> PS. Thread subject has become little different than thread content :)
>>
>> --
>> Matthijs Wensveen
>> Func. Internet Integration
>> W http://www.func.nl
>> T +31 20 4230000
>> F +31 20 4223500
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   


-- 
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Johan Compagner <jc...@gmail.com>.
There are many state things in a component. Wicket itself has only a
few like model/visibile/enable. But a developer could add many many
more.

In our project this is easily handled by our components. Every
component knows when it is changed, what ever it is and then a visitor
adds them to ajax. We have a fixed set of components so its not a big
problem.

On 7/4/08, Matthijs Wensveen <m....@func.nl> wrote:
> Matej Knopp wrote:
>> On Thu, Jul 3, 2008 at 9:51 AM, Matej Knopp <ma...@gmail.com> wrote:
>>
>>>> And there is some functionality in there that Wicket might
>>>> be better without. For example, onModelChanged / Changing
>>>> things become tricky when you share the same model between
>>>> different instances. And when using setModelObject() with an
>>>> object that is equal to the current model object, but a
>>>> different instance (such as a Hibernate-persisted object
>>>> bound to the correct session), you have to either do
>>>> getModel().setObject() or change the model comparator.
>>>>
>>>>
>>> setModelObject isn't the best idea IMHO. Models should support some
>>> kind of state change notifications, we might want to improve that for
>>> 1.5, though it probably wouldn't be very easy to do.
>>>
>> Well, we can hardly detect change of propertypromodels unless we pull
>> and compare the value every time...
>>
>
> Better state change notifications would be a huge improvement IMO
> because that way components could add themselves to AjaxRequestTarget
> when needed. Currently all Ajax functionality requires Ajaxified
> components to know about each other and when they should be displayed.
> Some kind of even mechanism as described in
> https://issues.apache.org/jira/browse/WICKET-1312 would definitely help,
> but a model-driven approach would be even better.
>
> I was thinking to support this using annotations and aspects and the
> likes, but I haven't had the time to create a proof of concept.
>
> Matthijs
>
> PS. Thread subject has become little different than thread content :)
>
> --
> Matthijs Wensveen
> Func. Internet Integration
> W http://www.func.nl
> T +31 20 4230000
> F +31 20 4223500
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matthijs Wensveen <m....@func.nl>.
Matej Knopp wrote:
> On Thu, Jul 3, 2008 at 9:51 AM, Matej Knopp <ma...@gmail.com> wrote:
>   
>>> And there is some functionality in there that Wicket might
>>> be better without. For example, onModelChanged / Changing
>>> things become tricky when you share the same model between
>>> different instances. And when using setModelObject() with an
>>> object that is equal to the current model object, but a
>>> different instance (such as a Hibernate-persisted object
>>> bound to the correct session), you have to either do
>>> getModel().setObject() or change the model comparator.
>>>
>>>       
>> setModelObject isn't the best idea IMHO. Models should support some
>> kind of state change notifications, we might want to improve that for
>> 1.5, though it probably wouldn't be very easy to do.
>>     
> Well, we can hardly detect change of propertypromodels unless we pull
> and compare the value every time...
>   

Better state change notifications would be a huge improvement IMO 
because that way components could add themselves to AjaxRequestTarget 
when needed. Currently all Ajax functionality requires Ajaxified 
components to know about each other and when they should be displayed. 
Some kind of even mechanism as described in 
https://issues.apache.org/jira/browse/WICKET-1312 would definitely help, 
but a model-driven approach would be even better.

I was thinking to support this using annotations and aspects and the 
likes, but I haven't had the time to create a proof of concept.

Matthijs

PS. Thread subject has become little different than thread content :)

-- 
Matthijs Wensveen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matej Knopp <ma...@gmail.com>.
On Thu, Jul 3, 2008 at 9:51 AM, Matej Knopp <ma...@gmail.com> wrote:
>>
>> And there is some functionality in there that Wicket might
>> be better without. For example, onModelChanged / Changing
>> things become tricky when you share the same model between
>> different instances. And when using setModelObject() with an
>> object that is equal to the current model object, but a
>> different instance (such as a Hibernate-persisted object
>> bound to the correct session), you have to either do
>> getModel().setObject() or change the model comparator.
>>
>
> setModelObject isn't the best idea IMHO. Models should support some
> kind of state change notifications, we might want to improve that for
> 1.5, though it probably wouldn't be very easy to do.
Well, we can hardly detect change of propertypromodels unless we pull
and compare the value every time...
>
> -Matej
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matej Knopp <ma...@gmail.com>.
>
> And there is some functionality in there that Wicket might
> be better without. For example, onModelChanged / Changing
> things become tricky when you share the same model between
> different instances. And when using setModelObject() with an
> object that is equal to the current model object, but a
> different instance (such as a Hibernate-persisted object
> bound to the correct session), you have to either do
> getModel().setObject() or change the model comparator.
>

setModelObject isn't the best idea IMHO. Models should support some
kind of state change notifications, we might want to improve that for
1.5, though it probably wouldn't be very easy to do.

-Matej

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Wed, 02 Jul 2008, Matej Knopp wrote:
> I still don't see what's wrong with GenericPanel. It's certainly much
> easier to type than ModelContainingPanel.

Nothing wrong with that either, it's just very generic :) 

There are a lot of ways of making use of generics in a
component besides just adding the type parameter bound to
the type parameter of the model of the component.

I mean, if you have

public FooPanel extends GenericPanel<Foo> {
    public FooPanel(String id, IModel<Foo> model, IModel<List<Bar>> bars) {
    ...
    }
...
}

it's not so much more generic than

public FooPanel extends Panel {
    public FooPanel(String id, IModel<Foo> model, IModel<List<Bar>> bars) {
    ...
    }
...
}

> I strongly disagree. There are good reasons for Wicket to bind model
> and component together and I think what we have in 1.4 right now is a
> balanced compromise. 

I'd be glad to hear more on this! For now, I imagine that a
lot of stuff that the Component IModel dependency exists for
could be done in other ways. 

And there is some functionality in there that Wicket might
be better without. For example, onModelChanged / Changing
things become tricky when you share the same model between
different instances. And when using setModelObject() with an
object that is equal to the current model object, but a
different instance (such as a Hibernate-persisted object
bound to the correct session), you have to either do
getModel().setObject() or change the model comparator.

Again, I'm just exploring, and perhaps overlooking
something.

> Also if we don't provide the convenience classes
> people will bound to write their own (because it's the only reasonable
> way to migrate project that already uses generics).

That's true, I just thought it would be no big deal and only
affect the earliest 1.4 adopters (or those still converting
from 2.0 if there are any left) (sorry :)). I had in mind
that if we then remove those convenience classes in 1.5,
they would have to move to the user codebases anyway, but
maybe 1.4 -> 1.5 will not be such a common migration path
because of API breaks.

> I don't buy this. Our components have a lot of methods, but most of
> them are not part of public API. I plan to prefix those methods with a
> common prefix for 1.5 so they don't confuse regular users. But I
> really don't see how removing four methods (*defaultModel) improves
> our api.

It would be better (altough harder) to move responsibilities 
away from Component to other classes, which could be then
marked as not being a part of the public API. When you do
the rename I'll be happy to do a spike of moving some of the
renamed stuff away from Component altogether :)

> Models have always been conceptually bound to component. Right now the
> problem of our API is not that we have a model slot in component. It
> is that we have exactly one model slot. This doesn't work well for all
> components, since some don't need model at all and some need more than
> one.

Yeah, if we cannot get rid of the default model handling
(which I still hope to be possible), at least a more
flexible abstraction (IModelsContainer?) might be good. 

> esier. Now thinking about it, the name should really suggest that
> there is one model per component. Maybe PanelWithModel could be the
> name after all :)

PanelWithExactlyOneModelInTheDefaultSlotAndHoldingAnObjectOfTheSameTypeAsTheTypeParameterOfThisComponent :)

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Matej Knopp <ma...@gmail.com>.
On Wed, Jul 2, 2008 at 4:28 AM, Timo Rantalaiho <Ti...@ri.fi> wrote:
> On Tue, 01 Jul 2008, Matej Knopp wrote:
>> There is one thing that helped me quite a lot when migration the
>> project I'm working out. I've created GenericPanel,
>> GenericWebMarkupContainer and GenericFragment classes. In most cases
>> the only change was renaming Panel<MyClass> to GenericPanel<MyClass>.
>
> Maybe the names could be TypedPanel / ModelContainingPanel
> or something like that?
I still don't see what's wrong with GenericPanel. It's certainly much
easier to type than ModelContainingPanel.
>
> Or maybe start with the original component name so that they
> would pop up more easily in the IDE, for example
> PanelWithType / PanelWithModel?
>
>> I was wondering, even though those classes were farily simple, we
>> might want to include them in Wicket anyway, for the sake of
>> consistency and convenience.
>
> I thought about this and I think that it might be better to
> not include them after all. In 1.5 it would be great to
> separate IModel and Component more thoroughly, getting rid
> of the defaultModel* accessors. Then it would make less
> sense to have the convenience classes with those model and
> modelObject accessors.
I strongly disagree. There are good reasons for Wicket to bind model
and component together and I think what we have in 1.4 right now is a
balanced compromise. Also if we don't provide the convenience classes
people will bound to write their own (because it's the only reasonable
way to migrate project that already uses generics).

>
> In cases where two components share the same model, it would
> make sense to make the IModel field in each component final.
> Then setModel() does not make sense any more; all it could
> do would be throw an exception or be a confusing no-op.
> Likewise, sometimes you never do setModelObject() or
> getModelObject() from outside the class.

You don't have to use those methods, there are for convenience only.

>
> Leaner APIs and less methods per objects are good things.
> Hence it's better to add methods as you need them, instead
> of providing a lot of convenience stuff that is only used a
> part of the time. Surely each Component subclass has anyway
> a lot of methods, and MarkupContainers even more, but you
> have got to start somewhere :)

I don't buy this. Our components have a lot of methods, but most of
them are not part of public API. I plan to prefix those methods with a
common prefix for 1.5 so they don't confuse regular users. But I
really don't see how removing four methods (*defaultModel) improves
our api.

We will always need some kind of utility methods for manipulating
models in component.

Models have always been conceptually bound to component. Right now the
problem of our API is not that we have a model slot in component. It
is that we have exactly one model slot. This doesn't work well for all
components, since some don't need model at all and some need more than
one.

Unfortunately the component <-> model contract is quite complicated as
we have compound models, componentassignedmodels, etc so a simple
property for model doesn't really cut it. We still need some kind of
model manipuation methods. Something like current setDefaultModel,...
but more flexible. And when we do have it, having
GenericPanel,Fragment,... might make the migration for users lot
esier. Now thinking about it, the name should really suggest that
there is one model per component. Maybe PanelWithModel could be the
name after all :)

-Matej

>
> This is not a big deal though, either way is fine by me.
>
> Best wishes,
> Timo
>
> --
> Timo Rantalaiho
> Reaktor Innovations Oy    <URL: http://www.ri.fi/ >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: generics

Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Tue, 01 Jul 2008, Matej Knopp wrote:
> There is one thing that helped me quite a lot when migration the
> project I'm working out. I've created GenericPanel,
> GenericWebMarkupContainer and GenericFragment classes. In most cases
> the only change was renaming Panel<MyClass> to GenericPanel<MyClass>.

Maybe the names could be TypedPanel / ModelContainingPanel 
or something like that?

Or maybe start with the original component name so that they
would pop up more easily in the IDE, for example
PanelWithType / PanelWithModel? 

> I was wondering, even though those classes were farily simple, we
> might want to include them in Wicket anyway, for the sake of
> consistency and convenience.

I thought about this and I think that it might be better to
not include them after all. In 1.5 it would be great to
separate IModel and Component more thoroughly, getting rid
of the defaultModel* accessors. Then it would make less
sense to have the convenience classes with those model and
modelObject accessors.

In cases where two components share the same model, it would
make sense to make the IModel field in each component final.
Then setModel() does not make sense any more; all it could
do would be throw an exception or be a confusing no-op.
Likewise, sometimes you never do setModelObject() or
getModelObject() from outside the class.

Leaner APIs and less methods per objects are good things.
Hence it's better to add methods as you need them, instead
of providing a lot of convenience stuff that is only used a
part of the time. Surely each Component subclass has anyway
a lot of methods, and MarkupContainers even more, but you
have got to start somewhere :)

This is not a big deal though, either way is fine by me.

Best wishes,
Timo

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org