You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris <ch...@gmx.at> on 2015/04/17 01:50:46 UTC
Wicket Listmodel (attach objects to model but not to list)
Hi all,
I have a listmodel:
IModel<List<A>> listModel = new ListModel<List<A>>(method.retrieveAlist());
Is it possible to feed the model from the original list but add additional elements of type A to the model only, without being mapped back to the list?
thanks a lot,
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Wicket Listmodel (attach objects to model but not to list)
Posted by Francois Meillet <fr...@gmail.com>.
It's not possible.
Look at the ListModel's consructor.
public ListModel(List<T> list)
{
setObject(list);
}
And the setObject() method implementation, which is in the superclass, is
@Override
public void setObject(T object)
{
if (!(object instanceof Serializable))
{
object = createSerializableVersionOf(object);
}
this.object = object;
}
François Meillet
Le 17 avr. 2015 à 01:50, Chris <ch...@gmx.at> a écrit :
> Hi all,
>
> I have a listmodel:
>
> IModel<List<A>> listModel = new ListModel<List<A>>(method.retrieveAlist());
>
> Is it possible to feed the model from the original list but add additional elements of type A to the model only, without being mapped back to the list?
>
> thanks a lot,
> Chris
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
Re: Wicket Listmodel (attach objects to model but not to list)
Posted by Chris <ch...@gmx.at>.
Hi Sven,
thanks a lot - works fine for me.
Christoph
> Am 17.04.2015 um 08:47 schrieb Sven Meier <sv...@meiers.net>:
>
> I'd solve it with a custom model:
>
> IModel<List<A>> listModel = new LoadableDetachableModel() {
> protected List<A> load() {
> List<A> as = new ArrayList<>();
>
> as.addAll(method.retrieveAlist());
>
> as.add(...);
>
> return as;
> }
> });
>
> Positive side effect: The list of object is not kept in the session and always up-to-date.
>
> Have fun
> Sven
>
>
> On 17.04.2015 01:50, Chris wrote:
>> Hi all,
>>
>> I have a listmodel:
>>
>> IModel<List<A>> listModel = new ListModel<List<A>>(method.retrieveAlist());
>>
>> Is it possible to feed the model from the original list but add additional elements of type A to the model only, without being mapped back to the list?
>>
>> thanks a lot,
>> Chris
>> ---------------------------------------------------------------------
>> 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: Wicket Listmodel (attach objects to model but not to list)
Posted by Sven Meier <sv...@meiers.net>.
I'd solve it with a custom model:
IModel<List<A>> listModel = new LoadableDetachableModel() {
protected List<A> load() {
List<A> as = new ArrayList<>();
as.addAll(method.retrieveAlist());
as.add(...);
return as;
}
});
Positive side effect: The list of object is not kept in the session and
always up-to-date.
Have fun
Sven
On 17.04.2015 01:50, Chris wrote:
> Hi all,
>
> I have a listmodel:
>
> IModel<List<A>> listModel = new ListModel<List<A>>(method.retrieveAlist());
>
> Is it possible to feed the model from the original list but add additional elements of type A to the model only, without being mapped back to the list?
>
> thanks a lot,
> Chris
> ---------------------------------------------------------------------
> 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