• 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

Ajax with Struts - Loading the lookup values in drop down

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am developing a struts application with Ajax.
Mainly I am using Ajax for populating the look up values in drop down based on some other drop down/text values.
I have successfully written ajax javascript.
What I am doing is, the javascript will call the action and forward it to an jsp whose content type is xml.
Then I am parsing the xml and load the values in the drop down.

javascript >> Action servlet >> xml file >> parsing in javascript >> loading drop down values in html.

I am also using the Struts Validation Framework.
What is the issue I am facing is, I am having the form with 25 - 30 fields.
After invoking the ajax and populated the look up values in drop down and if any input validation fails, it's loading again in the same page for displaying the error message and at that time whatever look up value loaded in drop down from ajax is getting vanished, obviously.

How can we resolve it? Please suggest me whether the approach I am using is right? Since most of my form feilds will have more than 20 - 30 fields and most of the drop down values will based on the one or more other drop down values.
Please help to suggest is there any other easy way (sample example/links) to do it in Ajax with Struts (mainly for drop down).
Below is my coding:



struts-config.xml


LookupValueInDropDown.jsp
------------------


reg.jsp


 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry.. I thouht posting this ajaz forum and posted here. help to move to ajax forum
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given that the Struts validator is involved, the HTML/JavaScript forum is not an appropriate location. Right here is just fine.
 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any inputs/suggestion/idea/advice/links on this???
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Submit the form via Ajax.
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
couple of ideas -
You can do ajax submit as David mentioned.
Or when you make a ajax call to bring up the dropdown list, save the list in session. and on jsp get the drop down list from the session.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic