File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Spin through listbox items and update selection status Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Spin through listbox items and update selection status" Watch "Spin through listbox items and update selection status" New topic
Author

Spin through listbox items and update selection status

nebber johnson
Greenhorn

Joined: Aug 12, 2008
Posts: 3
I have a form that contains several elements populated based on a database query. One such field is a list of employees which is basically the result of a select * sql. The listbox is correctly populated

The issue I'm having is that on a "edit" page I have a query that returns a specific record (lets say joe's record). What I need to do is spin through the list of possible items (Jack, Joe, Mary) and if the value matches the name returned in the second query then make the item selected. Here is how I think it would be done:
1) Populate listbox with all possible items
2) Select a specific transaction and return a name
3) Spin through listbox items and if the item value match the name then mark it selected.

Is this possible to do and if so how?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

Why not just do it all while you're building the element?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
nebber johnson
Greenhorn

Joined: Aug 12, 2008
Posts: 3
Mainly because it is two different SQLs. But your suggestion is a good one, I believe I can store the results of the specific fetch and compare the "all" fetch with those results to populate.

Thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

You should be performing all database operations long before you get to the JSP.
 
Don't get me started about those stupid light bulbs.
 
subject: Spin through listbox items and update selection status