• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using LazyList for String objects

 
Anu Korah
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does LazyList work only with javabeans and not with plain String objects?
Here's my problem. I have an ActionForm like this:

public class TestForm extends ActionForm{
private List descriptionList;
//similarly i have other List properties
private ImagebuttonBean delButtons;

private Factory buttonfactory = new Factory() {
public Object create() {
return new ImageButtonBean();
}
};

private Factory stringfactory = new Factory() {
public Object create() {
return new String("");
}
};


public List getDescriptionList(){
if (descritpionList==null){descriptionList=ListUtils.lazylist(newArrayList,stringfactory)}
return descriptionList;
}

public List getDeleteButtons(){
if (delButtons==null){delButtons=ListUtils.lazylist(newArrayList,buttonfactory)}
return delButtons;
}

public void setDescriptionList(List list){
descriptionList=list;
}

public void setDeleteButtons(List list){
delButtons=list;
}


}


I am prepopulating the descriptionList in Action class and the delButton List if filled with ImageButtonBeans and has the same size as the descriptionList. The data is displayed onto the jsp

Note: i am not using the indexed attribute in the html:text tag. And the form is stored in session.

Everything works fine ...i do not have problems submitting the form and redisplaying the form with the saved data.

The problem occurs when my session times out but my browser with this page is still open. After the timeout, if were i click on any of my Submit buttons, say one of the Delete buttons or the Submit buttons, I get an ArrayIndexOutofBoundException. All my action classes extend a base class where i do a timeout check which forwards to the Login page.

Earlier I had been using just plain Lists and I was getting the same problem, I thought Lazylists would solve the problem. In fact, i have another page, where i display some names using <bean:write> with a Delete button against each name. It works fine in this case. When session timesout, it neatly goes to the Login page.

I think that the problem in this form is because, I am using String objects. Is there a way to make Lazylists work with Strings. I checked the example on the StrutsCatalogLazyList...but its too late in the day for me to encapsulate the fields in another Javabean and used indexed attribute.

-Thanks
Anu
 
Anu Korah
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a followup to my earlier post, i was able to resolve the problem by using a GrowthList in place of a LazyList or Arraylist (from apache commons collection v3.2).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic