You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Tom Götz <to...@decoded.de> on 2015/11/11 10:48:01 UTC
PropertyModel pointing at an IModel property
Hi there,
I have the following situation:
MyClass extends Panel {
private IModel<String> someModel;
MyClass(String id) {
super(id);
add(new Label(„label“, PropertyModel.of(this, „someModel“));
}
}
But instead of displaying someModel’s modelObject, the Label displays someModel.toString(), which is how PropertyResolver is implemented (does not check if value instance IModel …). Is there a best practice how to handle such constructs?
Cheers,
Tom
Re: PropertyModel pointing at an IModel property
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
At first sight this proposal sounds natural and easy to implement.
But then we have to support the same for #setObject() and #detach().
Issues:
1) #set - do the application wants to set the model object or replace the
model itself ?!
2) #detach - Wicket will have to lookup the leaf object in #detach()
*always* just to see whether it is an IModel to detach it too. This will be
a cost that all apps should pay and very few of them will actually use.
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Wed, Nov 11, 2015 at 11:17 AM, Tom Götz <to...@decoded.de> wrote:
> Yeah, I can’t think of any situation where I’d prefer to see
> model.toString() instead of model.getObject().toString() …
>
> Tom
>
>
> > On 11.11.2015, at 11:12, Ernesto Reinaldo Barreiro <re...@gmail.com>
> wrote:
> >
> > So, you if last thing after the . is a model ==> So, if the last thing
> > after . is a model
> >
> > On Wed, Nov 11, 2015 at 11:11 AM, Ernesto Reinaldo Barreiro <
> > reiern70@gmail.com> wrote:
> >
> >> I see your point... I do not know if such a change could break existing
> >> applications. Thought I guess not. So, you if last thing after the . is
> a
> >> model, i.e. a.b -> b, is a model automatically call b.getObject
> >>
> >> On Wed, Nov 11, 2015 at 11:02 AM, Tom Götz <to...@decoded.de> wrote:
> >>
> >>> Yeah this will work, thanks. I did fear that somebody came around with
> >>> that proposal ;-)
> >>>
> >>> It would feel more „natural" if PropertyResolver/PropertyModel would
> care
> >>> about calling model.getObject() (if the target value is an instance of
> >>> IModel) though.
> >>>
> >>> Tom
> >>>
> >>>
> >>>> On 11.11.2015, at 10:51, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com>
> >>> wrote:
> >>>>
> >>>> What happens if you user "someModel.object"?
> >>>>
> >>>> On Wed, Nov 11, 2015 at 10:48 AM, Tom Götz <to...@decoded.de> wrote:
> >>>>
> >>>>>
> >>>>> Hi there,
> >>>>>
> >>>>> I have the following situation:
> >>>>>
> >>>>>
> >>>>> MyClass extends Panel {
> >>>>>
> >>>>> private IModel<String> someModel;
> >>>>>
> >>>>> MyClass(String id) {
> >>>>> super(id);
> >>>>> add(new Label(„label“, PropertyModel.of(this, „someModel“));
> >>>>> }
> >>>>>
> >>>>> }
> >>>>>
> >>>>>
> >>>>> But instead of displaying someModel’s modelObject, the Label displays
> >>>>> someModel.toString(), which is how PropertyResolver is implemented
> >>> (does
> >>>>> not check if value instance IModel …). Is there a best practice how
> to
> >>>>> handle such constructs?
> >>>>>
> >>>>> Cheers,
> >>>>> Tom
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>> --
> >>>> Regards - Ernesto Reinaldo Barreiro
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >>
> >>
> >> --
> >> Regards - Ernesto Reinaldo Barreiro
> >>
> >
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: PropertyModel pointing at an IModel property
Posted by Tom Götz <to...@decoded.de>.
Yeah, I can’t think of any situation where I’d prefer to see model.toString() instead of model.getObject().toString() …
Tom
> On 11.11.2015, at 11:12, Ernesto Reinaldo Barreiro <re...@gmail.com> wrote:
>
> So, you if last thing after the . is a model ==> So, if the last thing
> after . is a model
>
> On Wed, Nov 11, 2015 at 11:11 AM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
>
>> I see your point... I do not know if such a change could break existing
>> applications. Thought I guess not. So, you if last thing after the . is a
>> model, i.e. a.b -> b, is a model automatically call b.getObject
>>
>> On Wed, Nov 11, 2015 at 11:02 AM, Tom Götz <to...@decoded.de> wrote:
>>
>>> Yeah this will work, thanks. I did fear that somebody came around with
>>> that proposal ;-)
>>>
>>> It would feel more „natural" if PropertyResolver/PropertyModel would care
>>> about calling model.getObject() (if the target value is an instance of
>>> IModel) though.
>>>
>>> Tom
>>>
>>>
>>>> On 11.11.2015, at 10:51, Ernesto Reinaldo Barreiro <re...@gmail.com>
>>> wrote:
>>>>
>>>> What happens if you user "someModel.object"?
>>>>
>>>> On Wed, Nov 11, 2015 at 10:48 AM, Tom Götz <to...@decoded.de> wrote:
>>>>
>>>>>
>>>>> Hi there,
>>>>>
>>>>> I have the following situation:
>>>>>
>>>>>
>>>>> MyClass extends Panel {
>>>>>
>>>>> private IModel<String> someModel;
>>>>>
>>>>> MyClass(String id) {
>>>>> super(id);
>>>>> add(new Label(„label“, PropertyModel.of(this, „someModel“));
>>>>> }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> But instead of displaying someModel’s modelObject, the Label displays
>>>>> someModel.toString(), which is how PropertyResolver is implemented
>>> (does
>>>>> not check if value instance IModel …). Is there a best practice how to
>>>>> handle such constructs?
>>>>>
>>>>> Cheers,
>>>>> Tom
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Regards - Ernesto Reinaldo Barreiro
>>>
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>>
>> --
>> Regards - Ernesto Reinaldo Barreiro
>>
>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: PropertyModel pointing at an IModel property
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
So, you if last thing after the . is a model ==> So, if the last thing
after . is a model
On Wed, Nov 11, 2015 at 11:11 AM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:
> I see your point... I do not know if such a change could break existing
> applications. Thought I guess not. So, you if last thing after the . is a
> model, i.e. a.b -> b, is a model automatically call b.getObject
>
> On Wed, Nov 11, 2015 at 11:02 AM, Tom Götz <to...@decoded.de> wrote:
>
>> Yeah this will work, thanks. I did fear that somebody came around with
>> that proposal ;-)
>>
>> It would feel more „natural" if PropertyResolver/PropertyModel would care
>> about calling model.getObject() (if the target value is an instance of
>> IModel) though.
>>
>> Tom
>>
>>
>> > On 11.11.2015, at 10:51, Ernesto Reinaldo Barreiro <re...@gmail.com>
>> wrote:
>> >
>> > What happens if you user "someModel.object"?
>> >
>> > On Wed, Nov 11, 2015 at 10:48 AM, Tom Götz <to...@decoded.de> wrote:
>> >
>> >>
>> >> Hi there,
>> >>
>> >> I have the following situation:
>> >>
>> >>
>> >> MyClass extends Panel {
>> >>
>> >> private IModel<String> someModel;
>> >>
>> >> MyClass(String id) {
>> >> super(id);
>> >> add(new Label(„label“, PropertyModel.of(this, „someModel“));
>> >> }
>> >>
>> >> }
>> >>
>> >>
>> >> But instead of displaying someModel’s modelObject, the Label displays
>> >> someModel.toString(), which is how PropertyResolver is implemented
>> (does
>> >> not check if value instance IModel …). Is there a best practice how to
>> >> handle such constructs?
>> >>
>> >> Cheers,
>> >> Tom
>> >>
>> >>
>> >
>> >
>> > --
>> > Regards - Ernesto Reinaldo Barreiro
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>
--
Regards - Ernesto Reinaldo Barreiro
Re: PropertyModel pointing at an IModel property
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
I see your point... I do not know if such a change could break existing
applications. Thought I guess not. So, you if last thing after the . is a
model, i.e. a.b -> b, is a model automatically call b.getObject
On Wed, Nov 11, 2015 at 11:02 AM, Tom Götz <to...@decoded.de> wrote:
> Yeah this will work, thanks. I did fear that somebody came around with
> that proposal ;-)
>
> It would feel more „natural" if PropertyResolver/PropertyModel would care
> about calling model.getObject() (if the target value is an instance of
> IModel) though.
>
> Tom
>
>
> > On 11.11.2015, at 10:51, Ernesto Reinaldo Barreiro <re...@gmail.com>
> wrote:
> >
> > What happens if you user "someModel.object"?
> >
> > On Wed, Nov 11, 2015 at 10:48 AM, Tom Götz <to...@decoded.de> wrote:
> >
> >>
> >> Hi there,
> >>
> >> I have the following situation:
> >>
> >>
> >> MyClass extends Panel {
> >>
> >> private IModel<String> someModel;
> >>
> >> MyClass(String id) {
> >> super(id);
> >> add(new Label(„label“, PropertyModel.of(this, „someModel“));
> >> }
> >>
> >> }
> >>
> >>
> >> But instead of displaying someModel’s modelObject, the Label displays
> >> someModel.toString(), which is how PropertyResolver is implemented (does
> >> not check if value instance IModel …). Is there a best practice how to
> >> handle such constructs?
> >>
> >> Cheers,
> >> Tom
> >>
> >>
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Regards - Ernesto Reinaldo Barreiro
Re: PropertyModel pointing at an IModel property
Posted by Tom Götz <to...@decoded.de>.
Yeah this will work, thanks. I did fear that somebody came around with that proposal ;-)
It would feel more „natural" if PropertyResolver/PropertyModel would care about calling model.getObject() (if the target value is an instance of IModel) though.
Tom
> On 11.11.2015, at 10:51, Ernesto Reinaldo Barreiro <re...@gmail.com> wrote:
>
> What happens if you user "someModel.object"?
>
> On Wed, Nov 11, 2015 at 10:48 AM, Tom Götz <to...@decoded.de> wrote:
>
>>
>> Hi there,
>>
>> I have the following situation:
>>
>>
>> MyClass extends Panel {
>>
>> private IModel<String> someModel;
>>
>> MyClass(String id) {
>> super(id);
>> add(new Label(„label“, PropertyModel.of(this, „someModel“));
>> }
>>
>> }
>>
>>
>> But instead of displaying someModel’s modelObject, the Label displays
>> someModel.toString(), which is how PropertyResolver is implemented (does
>> not check if value instance IModel …). Is there a best practice how to
>> handle such constructs?
>>
>> Cheers,
>> Tom
>>
>>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: PropertyModel pointing at an IModel property
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
What happens if you user "someModel.object"?
On Wed, Nov 11, 2015 at 10:48 AM, Tom Götz <to...@decoded.de> wrote:
>
> Hi there,
>
> I have the following situation:
>
>
> MyClass extends Panel {
>
> private IModel<String> someModel;
>
> MyClass(String id) {
> super(id);
> add(new Label(„label“, PropertyModel.of(this, „someModel“));
> }
>
> }
>
>
> But instead of displaying someModel’s modelObject, the Label displays
> someModel.toString(), which is how PropertyResolver is implemented (does
> not check if value instance IModel …). Is there a best practice how to
> handle such constructs?
>
> Cheers,
> Tom
>
>
--
Regards - Ernesto Reinaldo Barreiro