You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by dlipski <da...@gmail.com> on 2008/10/01 09:34:24 UTC

Re: PropertyModel type of key map

Ok, maybe you are right that adding such method to PropertyModel will make it
bloated, but I think that some model dedicated to work with maps(MapModel ?)
will be nice feature of Wicket.

I know that questions bellow dont stick to the subject of this thread but
maybe you can help me with them. Recently i started to 'study' Wicket API
and Wicket sources and have two questions(so far ;)):

1)What IChainingModel interface is for ? I thought that it will be used
inside model implementations in getObject method checkig if nested model
object is a ChainingModel object but the instance of operator in this
methods checks against IModel interface (what is correct). If I understand
Wicket API correctly it is possible to implement some model with chainnig
ability without implementing IChaininig model - its internal implementation
of get/setObject methods. Could you explain me what I(or rather my model)
gain when my model implements IChaininigModel interface ?

2)When I looked at getTarget() method inside  PropertyModel class I found
that retriving of model object is done inside a loop. I dont understand why
PropertyModel cares about how nested model is implemented. Why it cares ?
because it checks if object returned but nested model is another nested
model or not. I thought that retriving of model object is responisbility of
each model class individually and PropertyModel should only check if its
model object is IModel object (if so return
((IModel)myModelObject).getObject) or is it a 'real' model object(if so
return it).

Answers for this questions will help me implementing my MapModel class.

Tanks for your help,
Regards Daniel


igor.vaynberg wrote:
> 
> why? because propertymodel is a convinience class only. once we start
> adding things like this into it it will get bloated. it is pretty easy
> to roll your own implementing imodel directly.
> 
> -igor
> 
> On Tue, Sep 30, 2008 at 10:53 AM, dlipski <da...@gmail.com>
> wrote:
>>
>> If there is no option to force (why? I can imagine setMapKeyClass method
>> in
>> PropertyModel...) PropertyModel to do this and I have to use different
>> Model, I would like to ask does Wicket(or one of Wicket subprojects such
>> as
>> WicketExtensions) provide such ready to use model ?
>>
>> Daniel Lipski
>>
>> igor.vaynberg wrote:
>>>
>>> dont use a property model, roll your own
>>>
>>> -igor
>>>
>>> On Tue, Sep 30, 2008 at 8:31 AM, dlipski <da...@gmail.com>
>>> wrote:
>>>>
>>>> Hi
>>>>
>>>> Im trying to 'force' PropertyModel to put into map key different then
>>>> String
>>>> but after few trials I have no idea how to do this.
>>>>
>>>> Example:
>>>> I have field myMap in my page initialized as follows:
>>>>
>>>> Map<Long, Boolean> myMap = new HashMap<Long, Boolean>();
>>>>
>>>> then I create property model for my page(this == page containing myMap
>>>> field):
>>>> PropertyModel p = new PropertyModel (this, "myMap[123]");
>>>>
>>>> now when I execute:
>>>> p.setObject(true);
>>>> model puts into map expected boolean but key is of type String not
>>>> Long.
>>>> How I can force this property model to put with key of choosen class
>>>> (in
>>>> this example Long)?
>>>>
>>>> Regards
>>>> Daniel Lipski
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/PropertyModel-type-of-key-map-tp19744489p19744489.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
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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/PropertyModel-type-of-key-map-tp19744489p19747226.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
>>
>>
> 
> ---------------------------------------------------------------------
> 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/PropertyModel-type-of-key-map-tp19744489p19755807.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: PropertyModel type of key map

Posted by Igor Vaynberg <ig...@gmail.com>.
i think that interface is legacy left over code. open a jira issue to
have it cleaned up.

-igor

On Wed, Oct 1, 2008 at 12:34 AM, dlipski <da...@gmail.com> wrote:
>
> Ok, maybe you are right that adding such method to PropertyModel will make it
> bloated, but I think that some model dedicated to work with maps(MapModel ?)
> will be nice feature of Wicket.
>
> I know that questions bellow dont stick to the subject of this thread but
> maybe you can help me with them. Recently i started to 'study' Wicket API
> and Wicket sources and have two questions(so far ;)):
>
> 1)What IChainingModel interface is for ? I thought that it will be used
> inside model implementations in getObject method checkig if nested model
> object is a ChainingModel object but the instance of operator in this
> methods checks against IModel interface (what is correct). If I understand
> Wicket API correctly it is possible to implement some model with chainnig
> ability without implementing IChaininig model - its internal implementation
> of get/setObject methods. Could you explain me what I(or rather my model)
> gain when my model implements IChaininigModel interface ?
>
> 2)When I looked at getTarget() method inside  PropertyModel class I found
> that retriving of model object is done inside a loop. I dont understand why
> PropertyModel cares about how nested model is implemented. Why it cares ?
> because it checks if object returned but nested model is another nested
> model or not. I thought that retriving of model object is responisbility of
> each model class individually and PropertyModel should only check if its
> model object is IModel object (if so return
> ((IModel)myModelObject).getObject) or is it a 'real' model object(if so
> return it).
>
> Answers for this questions will help me implementing my MapModel class.
>
> Tanks for your help,
> Regards Daniel
>
>
> igor.vaynberg wrote:
>>
>> why? because propertymodel is a convinience class only. once we start
>> adding things like this into it it will get bloated. it is pretty easy
>> to roll your own implementing imodel directly.
>>
>> -igor
>>
>> On Tue, Sep 30, 2008 at 10:53 AM, dlipski <da...@gmail.com>
>> wrote:
>>>
>>> If there is no option to force (why? I can imagine setMapKeyClass method
>>> in
>>> PropertyModel...) PropertyModel to do this and I have to use different
>>> Model, I would like to ask does Wicket(or one of Wicket subprojects such
>>> as
>>> WicketExtensions) provide such ready to use model ?
>>>
>>> Daniel Lipski
>>>
>>> igor.vaynberg wrote:
>>>>
>>>> dont use a property model, roll your own
>>>>
>>>> -igor
>>>>
>>>> On Tue, Sep 30, 2008 at 8:31 AM, dlipski <da...@gmail.com>
>>>> wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> Im trying to 'force' PropertyModel to put into map key different then
>>>>> String
>>>>> but after few trials I have no idea how to do this.
>>>>>
>>>>> Example:
>>>>> I have field myMap in my page initialized as follows:
>>>>>
>>>>> Map<Long, Boolean> myMap = new HashMap<Long, Boolean>();
>>>>>
>>>>> then I create property model for my page(this == page containing myMap
>>>>> field):
>>>>> PropertyModel p = new PropertyModel (this, "myMap[123]");
>>>>>
>>>>> now when I execute:
>>>>> p.setObject(true);
>>>>> model puts into map expected boolean but key is of type String not
>>>>> Long.
>>>>> How I can force this property model to put with key of choosen class
>>>>> (in
>>>>> this example Long)?
>>>>>
>>>>> Regards
>>>>> Daniel Lipski
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/PropertyModel-type-of-key-map-tp19744489p19744489.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
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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/PropertyModel-type-of-key-map-tp19744489p19747226.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
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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/PropertyModel-type-of-key-map-tp19744489p19755807.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
>
>

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