You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Simon Kitching <sk...@apache.org> on 2005/11/29 11:33:25 UTC

[collections] new sublist type?

Hi,

I'd like opinions on adding a new collection type which represents a
"sublist" of some larger list of data.

  public interface Sublist {
    public int getStartOffset();
    public int getDatasetSize();
    public List getSublistData();
  }

Where getSublistData() is a list of elements from some "complete"
dataset. Property datasetSize is the size of the complete set, not the
size of the sublist.

Note that I'm talking here about situations where the "complete" dataset
cannot be loaded into memory due to size. Typically the data is stored
within a database.

The use case for this is as follows:
 The presentation tier of an application wants to allow a user
 to view a *large* set of available data one "page" at a time. 
 It needs to know the full size of the available data

 The business level of the application therefore needs to be
 able to return some collection representing a "sublist" of
 the available data.

In particular, I've struck this need when writing an application using
JSF [myfaces] and EJB3. I'd like to add a generic component to the
MyFaces library which can handle paginated data. However the "sublist"
type returned by the EJBs shouldn't be a type from the MyFaces library;
that would be very bad style. A "sublist" type available from the
commons-collections library would form an excellent "bridge" between the
two worlds (business and presentation).

Thoughts?

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [collections] new sublist type?

Posted by Thomas Dudziak <to...@gmail.com>.
On 11/29/05, Simon Kitching <sk...@apache.org> wrote:

> Note that I'm talking here about situations where the "complete" dataset
> cannot be loaded into memory due to size. Typically the data is stored
> within a database.
>
> The use case for this is as follows:
>  The presentation tier of an application wants to allow a user
>  to view a *large* set of available data one "page" at a time.
>  It needs to know the full size of the available data
>
>  The business level of the application therefore needs to be
>  able to return some collection representing a "sublist" of
>  the available data.
>
> In particular, I've struck this need when writing an application using
> JSF [myfaces] and EJB3. I'd like to add a generic component to the
> MyFaces library which can handle paginated data. However the "sublist"
> type returned by the EJBs shouldn't be a type from the MyFaces library;
> that would be very bad style. A "sublist" type available from the
> commons-collections library would form an excellent "bridge" between the
> two worlds (business and presentation).

I don't know anything about JSF/EJB in particular, but when for
instance I want to show a large collection in Struts, I'd use a proxy
list that maintains a 'frame' of the data of a pre-specified size
which it is able to fetch from the database.
This way, there is no need to create new functions on the view side
because it thinks it works with a normal list - e.g. c:forEach or
displaytag work without problems.

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org