This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I didn't take a close look at your code -- looking at a bunch of Struts tags is less than illuminating -- but the premise of the dependent drowdown is fairly easy.
1. When a selection is made from dropdown #1, an Ajax request is made to a server-side resource with the value chosen. 2. Using that value, the server-side resource collects and returns the list of values that are to become the options of dropdown #2. I usually employ JSON for this purpose as it's easy to digest on the client. 3. The client handler for the request converts the JSON to a Javascript construct and uses the information to add the options to dropdown #2.
A cursory look at your code reveals that you are doing all the Ajax stuff directly. That's madness in my opinion. Better to get acquainted with one of the toolkits that vastly simplifies the process by masking browser dependencies and that handle the ready-change protocol. I'm partial to Prototype and jQuery myself.
If you want to implement your resource as a Struts Action, then you would address it just like any other action. The difference would be in what the Action returns as the response. Instead of a full HTML page, the response would be the text of a JSON construct or an XML document or however else you decide to return the option data to the client.
Kunal Sathe
Ranch Hand
Joined: Apr 08, 2005
Posts: 48
posted
0
Hey Bear,
The following is what I am trying to do. Please let me know if I am headed in the right direction.
From the Javascript in the JSP Page, i am calling the retrieveURL method where I am passing the Struts Entry as shown below
I have a Struts Entry as follows in the Struts Config file
The control is flowing to the ShowAjaxAction class. Should I be creating a JSON Object in the ShowAction class? Also how do I pass it to the JSP and how do I use it in the JSP page.
Any comment will be highly appreciated.
Regards, Kunal
Kunal Sathe
Ranch Hand
Joined: Apr 08, 2005
Posts: 48
posted
0
Thanks for your help Bear!
I have been successfully implemented the solution.