Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming 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
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

extracting some elements from ArrayList on JSP

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's how I used to do it:

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 ]
 
This tiny ad is suggesting that maybe she should go play in traffic.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!