This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
hello everyone. On my JSP i am having a dropdown box to select a category. and on selection of that i want all its subcategories to be displayed in another dropdown box. now the thing is that my categoryBean contains CatagoryId,CategoryName,ParentCategoryId. and list of all categories(including all subcategories and everything) are inside CategoryList(ArrayList) and i have.... <html:select property="category" size="1"> <jsp:useBean id="categoryList" class="java.util.ArrayList" scope="session" /> <html ptions collection="categoryList" labelProperty="catName" property="catId"/></html:select></td>
now when user selects a category... how can i check that the categories are containg XYZ as its parent category??? and how to get them in another dropdown box??? any help will be appriciated... thank you...
1. Code an "onchange" event in the first dropdown that submits the form 2. Have the action class read the option selected in the first dropdown and build the list for the second dropdown 3. Redispaly the page, putting the focus on the second dropdown.
Now, I use AJAX, which is much smoother and doesn't require a redisplay of the page. Here's roughly how it works:
1. code an "onchage event in the first dropdown that makes an AJAX call to the server. 2. Code a server Method that will return a list of options based on what was selected in the first. 3. The "callback function" of the AJAX call takes the list of options returned and uses the Document Object Model (DOM) to build a second dropdown with the list of options.
This option requires learning some of the principles of AJAX, though, and will involve a bit of a learning curve. I'd suggest using DWR as a framework for your AJAX calls. [ June 12, 2006: Message edited by: Merrill Higginson ]