• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using LazyList for String objects

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic