Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts and Ajax

 
Sahil Dave
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
 
Kevin Biesbrock
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
  •  
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64683
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • 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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic