Oh, I misunderstood.  Sorry!  Off the top of my head without much
thought, I would just create a ThirtyRecordsAction which would have a
boolean switch for downloading the records or maybe create a special
data structure just for this.  I use a fairly standard list iterator
and handler pattern which I grabbed somewhere.  Here are the classes:

package com.crackwillow.util.list;

import java.util.Collection;
import java.util.List;

import com.crackwillow.exception.ChainedException;

public interface ListIterator {
  public void       setList(List list) throws ChainedException;
  public Collection getList();
  public int        getSize() throws ChainedException;
  public void       setIndex(int index) throws ChainedException;
  public int        getCurrentIndex() throws ChainedException;
  public Object     getCurrentElement() throws ChainedException;
  public List       getPreviousElements(int count) throws ChainedException;
  public List       getPreviousElements() throws ChainedException;
  public List       getNextElements(int count) throws ChainedException;
  public List       getNextElements() throws ChainedException;
  public void       resetIndex() throws ChainedException;
} /// ;-)

package com.crackwillow.util.list;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.crackwillow.exception.ChainedException;

public class ListHandler
    implements com.crackwillow.util.list.ListIterator {
  static Log log = LogFactory.getLog(ListHandler.class);

  private List         list;
  private ListIterator listIterator;

  public ListHandler() {
  }

  public void setList(List list)
      throws ChainedException {
    this.list = list;
    if(list != null) {
      listIterator =  list.listIterator();
    } else {
      throw new ChainedException("ListHandler: setList(List) failed:
list empty");
    }
  }

  public Collection getList() {
    return list;
  }

  public int getSize()
      throws ChainedException{
    int size = 0;
    if (list != null) {
      size = list.size();
    } else {
      throw new ChainedException("ListHandler: getList() failed"); //No Data
    }
    return size;
  }

  public void setIndex(int index)
      throws ChainedException {
    index -= getCurrentIndex();
    int size = list.size();
    if(index > size) {
      throw new ChainedException("ListHandler: setCurrentIndex()
failed -- the current index chosen was greater than size)");
    }
    getNextElements(index);
    return;
  }

  public int getCurrentIndex()
      throws ChainedException {
    // Will not advance iterator
    if (list != null) {
      return listIterator.nextIndex();
    } else {
      throw new ChainedException();
    }
  }

  public Object getCurrentElement()
      throws ChainedException {
    Object obj = null;
    // Will not advance iterator
    if (list != null) {
      int currIndex = listIterator.nextIndex();
      obj = list.get(currIndex);
    } else {
      throw new ChainedException();
    }
    return obj;
  }

  public List getPreviousElements(int count)
      throws ChainedException {
    int        i      = 0;
    Object     object = null;
    LinkedList list   = new LinkedList();
    if (listIterator != null) {
      while(listIterator.hasPrevious() && (i < count)){
        object = listIterator.previous();
        list.add(object);
        i++;
      }
    } else {
      throw new ChainedException("ListHandler:
getPreviousElements(int) failed -- listIterator null."); // No data
    }
    return list;
  }

  public List getPreviousElements()
      throws ChainedException {
    Object object = null;
    LinkedList list = new LinkedList();
    if(listIterator != null) {
      while(listIterator.hasPrevious()) {
        object = listIterator.previous();
        list.add(object);
      }
    } else {
      throw new ChainedException("ListHandler: getNextElements(int)
failed -- listIterator null");
    }
    return list;
  }

  public List getNextElements(int count)
      throws ChainedException {
    int        i      = 0;
    Object     object = null;
    LinkedList list   = new LinkedList();
    if(listIterator != null) {
      while(listIterator.hasNext() && (i < count)) {
        object = listIterator.next();
        list.add(object);
        i++;
      }
    } else {
      throw new ChainedException("ListHandler: getNextElements(int)
failed -- listIterator null.");
    }
    return list;
  }

  public List getNextElements()
      throws ChainedException {
    Object object = null;
    LinkedList list = new LinkedList();
    if(listIterator != null) {
      while(listIterator.hasNext()) {
        object = listIterator.next();
        list.add(object);
      }
    } else {
      throw new ChainedException("ListHandler: getNextElements(int)
failed -- listIterator null");
    }
    return list;
  }

  public List getNext()
      throws ChainedException {
    Object object = null;
    LinkedList list = new LinkedList();

    if(listIterator != null) {
      if(listIterator.hasNext()) {
        object = listIterator.next();
        list.add(object);
      }
    } else {
      throw new ChainedException("ListHandler: getNextElements(int)
failed -- listIterator null");
    }

    return list;
  }

  public void resetIndex()
      throws ChainedException{
    if(listIterator != null){
      listIterator = list.listIterator();
    } else {
      throw new ChainedException("ListHandler: resetIndex() failed --
listIterator null.");
    }
  }
} ///;-)

You might also use an ArrayListWrapper and remove(0)

package com.crackwillow.util.list;

import java.util.ArrayList;

public class ArrayListWrapper
    extends ArrayList {
  private ArrayListWrapper(Object [] param) {
    for(int i = 0; i < param.length; i++) {
      this.add(param[i]);
    }
  }

  public static ArrayList getInstance(Object [] param) {
    return new ArrayListWrapper(param);
  }
}

Hope this helps,

Jack


On Thu, 23 Dec 2004 19:56:08 +0530, uma.k <[EMAIL PROTECTED]> wrote:
> Hi Jack,
> I havent yet started working on the application. Before I start I thought I
> would get some good ideas to do the application in a better way. Any way I
> will start and get back to you if there is any.
> 
> Thanks
> Uma
> 
> -----Original Message-----
> From: Dakota Jack [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 23, 2004 7:45 PM
> To: uma.k
> Subject: Re: some logic help
> 
> Your question needs to be more specific, Uma.  What are you having
> difficulty with in particular?
> 
> Jack
> 
> On Thu, 23 Dec 2004 14:35:18 +0530, uma.k <[EMAIL PROTECTED]> wrote:
> > Hi Jack,
> > I need some ideas on developing another small application. I have already
> > done this in JSP and
> > servlets.
> >
> > The application gets 30 records from the database, I put them into a
> > collection and the collection
> > into the session object. I pick up the first element from the collection
> and
> > display to the user
> > and delete that element from the collection and update the session with
> the
> > remaining elements.
> > This goes on till the 30 elements.
> >
> > This is all done in the same JSP. If I have to do the same in Struts, How
> to
> > do this?
> >
> > Thanks
> > Uma
> >
> >
> 
> --
> ------------------------------
> 
> "You can lead a horse to water but you cannot make it float on its back."
> 
> ~Dakota Jack~
> 
> "You can't wake a person who is pretending to be asleep."
> 
> ~Native Proverb~
> 
> "Each man is good in His sight. It is not necessary for eagles to be crows."
> 
> ~Hunkesni (Sitting Bull), Hunkpapa Sioux~
> 
> -----------------------------------------------
> 
> "This message may contain confidential and/or privileged information.
> If you are not the addressee or authorized to receive this for the
> addressee, you must not use, copy, disclose, or take any action based
> on this message or any information herein. If you have received this
> message in error, please advise the sender immediately by reply e-mail
> and delete this message. Thank you for your cooperation."
> 
> 


-- 
------------------------------

"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

-----------------------------------------------

"This message may contain confidential and/or privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation."

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to