• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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!
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic