• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Pass List of Strings back to Action Form

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have searched all over google looking for this answer. I am using Struts 1.2 and I have a handful of select boxes in my jsp page that will not all be filled in at once. I am looking for a way to pass back the strings in the select boxes to the ActionForm in order to be able to display it in the jsp page without refilling it in from the database nor saving it as a session attribute.

I have tried to use the data coming into the jsp page as a: Vector, List, String[], and an ArrayList. I am trying to use an iterate over the list and the html:hidden tag to force it back to the action form each time. This works with an actual object with individual fields like: name, address, city. But I cannot get it to work for an array of Strings like Dan, Emily, John.

Scenario:
I fill in the first selection box indList. Upon selecting a selection in the box, I go perform an action and fill in the other selection boxes and return the same action form with the same jsp page where I had hidden the indList in hopes it would return too. Instead, the indList is now blank, the other lists have been populated.

here is a snippet of my code, this time trying to use a Vector:

Jsp:


ActionForm



Any help is appreciated.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand your requirement, please restate it.
and I don't understand the provision of this null check, its not usually done.
 
veronica jones
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, the requirement is that I am trying to save the list of industries from the indList that is a Vector when the form is submitted so I do not lose this data when the form is redisplayed. I am trying to avoid making another database call to get this indList populated again. Upon this first submit, the user will have selected an industry, other selections on the page will now show up and be populated based on this selection. However, I am loosing the indList. This is the reason for the null check so the page displays with an empty indList instead of bombing out on a null exception.

I am trying to save the indList in a html:hidden field by iterating through the indList and saving the data in the ActionForm.



Here is my jsp:



ActionForm:




I was hoping that setIndInfo would be called via the iterate tag and reset the indList in the ActionForm to save this data upon a submit. But this method is never called.

Thanks for your help.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, you're doing it wrong, this is the wrong syntax for setter

And you can see, there is no use of index, setter takes only one parameter.

What you want is the list data has to be persisted between several request, then I would advise you to use "session" scope ActionForm.
 
veronica jones
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thanks that is what I was afraid of. I was trying not use Session.
 
keep an eye out for scorpions and black widows. But the tiny ads are safe.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic