the jdk provides it.
Gili wrote:
I like the List interface, it's standard and complete. Why not
provide an abstract list for others to extend if you want to make
things easier?
Gili
On Tue, 08 Mar 2005 13:09:18 -0800, Jonathan Locke wrote:
actually, one nice thing about list is that the contract is looser. if
we make an interface like the one below and we forget a method, we've
set in stone how we access lists. the list interface is a pretty
complete set of semantics for dealing with lists... which is why i
initially selected it.
but i think you're probably correct. we should stew on this though...
what about choice lists? should those use the same list model interface?
Jan Blok wrote:
Hi,
Is there a reason to use a java.util.List interface in the first place?
Which is quite big to implement for many people, why not define an
Interface alike javax.swing.ListModel? For example
Public interface IListViewModel
{
public Object getObjectAt(int index);
public int getSize()
//more needed?
}
I think many people have to put there own list objects in a
(Lazy)ArrayList again...which they do already hold in (lazy loading)
models.
Regards Jan
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Eelco Hillenius
Sent: Tuesday, March 08, 2005 8:11 PM
To: [email protected]
Subject: Re: [Wicket-develop] should we make AbstractResource
serializeable or not?
We're in the process of reconsidering the ListView
implementation alltogether I think.
If you really want this, you could provide a custom list that
does this. That list could lazily load it's size: when not
set yet, you load the actual list (e.g. from a database), but
when set, return it. And then the actual loading should occur
when one of it's accessor methods (like get(int) is called.
E.g (haven't tested it, but the idea should work):
public class LazyList extends ArrayList
{
private int size = -1;
private boolean loaded = false;
public LazyList(List list)
{
addAll(list);
}
public int size()
{
if(size == -1)
{
load();
this.size = super.size();
}
}
public get(int index)
{
load();
return super.get(index);
}
public void unload()
{
this.loaded = false;
}
private void load()
{
if(!loaded)
{
this.loaded = true;
// do loading here and call super.addAll(..)
}
}
.... etc ....
}
and your model is like:
public class MyModel extends AbstractDetachableModel
private LazyList myList; // keep reference to list allways;
it'll usually be empty
protected void onAttach()
{
if(myList == null)
{
myList = new LazyList(getSomeList());
}
}
protected void onDetach()
{
myList.unload();
}
protected Object onGetObject(Component component)
{
return myList;
}
.... etc ....
Btw, this might be a usefull pattern to either put on the
Wiki or in contrib. It's far more efficient for those cases
where you have a list that doesn't change over requests, are
that you want to 'push' the changes in, together with a
ListView that doesn't remove it's items on each request.
Eelco
It just happens that in my case - using a ListView - the
list view calls
getModelObject within the onRender method (via getViewSize)
this is causing
my detached model to re-attach for every request - even repeated
IredirectListener requests.
Could this component possibly be changed to remember the
size of the list ?
Cameron
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from
real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Wicket-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-develop