Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Struts and Ajax

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..

I am creating a web app in Struts 1.3. One of the JSPs has a requirement wherein a multiselect box and a textbox need to get filled, based on the selection in a dropdown.
I am not sure if there is any standard/well known way of doing this in Struts.
Any suggestions/pointers would be really great.

Thanks
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My approach to this would be to make an AJAX call to an action mapped behind a JSON namespace (e.g., myApp/json/getObject.action) passing the value of the select field (e.g., ?mySelect=1). Use the response to populate the multi-select and/or text box using JavaScript.

I've never used it, myself, but you might look into the dojo plug-in. Of course, you don't need to use dojo. If you're used to another js library, use it. I use prototype (js framework lib) and scriptaculous (effects engine lib). I would also use the json plug-in for your responses. It's very simple to set up and use. It basically just maps your action as json.

Hope that helps get you started.

Resources:
  • json example
  • dojo & ajax example
  • prototype & ajax
  • script.aculo.us
  •  
    Kevin Biesbrock
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Shoot. I didn't see that you were using Struts 1.3....so I'm not sure how much of what I said was relevant.

    Also...why 1.3?!?! Get with the times, man! ;)

    Kevin Biesbrock wrote:My approach to this would be to make an AJAX call to an action mapped behind a JSON namespace (e.g., myApp/json/getObject.action) passing the value of the select field (e.g., ?mySelect=1). Use the response to populate the multi-select and/or text box using JavaScript.

    I've never used it, myself, but you might look into the dojo plug-in. Of course, you don't need to use dojo. If you're used to another js library, use it. I use prototype (js framework lib) and scriptaculous (effects engine lib). I would also use the json plug-in for your responses. It's very simple to set up and use. It basically just maps your action as json.

    Hope that helps get you started.

    Resources:

  • json example
  • dojo & ajax example
  • prototype & ajax
  • script.aculo.us
  •  
    Marshal
    Posts: 67463
    173
    Mac Mac OS X IntelliJ IDE jQuery Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    At this point, Prototype and Scriptaculous are dinosaurs. You might want to investigate jQuery.
     
    Kevin Biesbrock
    Greenhorn
    Posts: 4
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Bear Bibeault wrote:At this point, Prototype and Scriptaculous are dinosaurs. You might want to investigate jQuery.



    haha. okay...

    [edit]
    ...although, I just found a performance comparison and....looks like you have a point. Sorry to doubt you, sir

    Might be time to switch...even though I really like the syntax of prototype.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic