• 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

declare arraylist as hidden field in the jsp

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I have a form which has an ArrayList of Customer objects.


CustomerForm{
priavte ArrayList custList;
//getter and setter methods
}

Customer{
private String fname;
private String lname;
//other variables and get set methods
}

Can some one let me know how to declare a hidden field for the custList in the struts jsp? Thanks a lot for your help.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't. Anything you put in a hidden field must be a String (or at least an object that can be converted to a String). You can't put an ArrayList in a single hidden field.

If I were you, I'd just put this ArrayList in session scope. Then you can retrieve anywhere you need it. As long as you remove it when it's no longer needed, I doubt it would affect performance significantly.

If you insist on doing it the hard way, though, here's one possibility:

If all of the Customer properties are Strings, you could iterate through the ArrayList using <logic:iterate> and create hidden fields with indexed properties for each customer in the list. If you're unfamiliar with indexed properties, the links below will help you understand them:

http://struts.apache.org/1.2.x/faqs/indexedprops.html

http://wiki.apache.org/struts/StrutsCatalogLazyList
[ July 24, 2006: Message edited by: Merrill Higginson ]
 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your response Merrill.
I have set the arraylist in the session scope as you have mentioned.
Just wanted to know if there was a way to avoid it but it seems to be a more convenient way.

Thanks again!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic