Populate data from a database into option values

J

jross

Hi all,

I need to grab data from a database and populate an option value with
the results. I have have written some code already just need to know if
im on the right path. I'm using JDK1.4 and JBoss-2.4.4_Tomcat-3.2.3.

Here is my java class

http://pastebin.com/m4eea38f3

Here is my jsp

http://pastebin.com/m6435cc92

I'm wondering if I'm able to load the Hashmap ListStores.loadStore() in
the option value like I have done? will this populate the option value
with the sql results. I want less as possible java code in the jsp. Any
feedback would be great. I used pastebins because it seems the best way
to display code.

jross
 
J

jross

jross said:
Hi all,

I need to grab data from a database and populate an option value with
the results. I have have written some code already just need to know if
im on the right path. I'm using JDK1.4 and JBoss-2.4.4_Tomcat-3.2.3.

Here is my java class

http://pastebin.com/m4eea38f3

Here is my jsp

http://pastebin.com/m164d39e8 I changed the jsp

I'm wondering if I'm able to load the Hashmap ListStores.loadStore() in
the option value like I have done? will this populate the option value
with the sql results. I want less as possible java code in the jsp. Any
feedback would be great. I used pastebins because it seems the best way
to display code.

jross
 
A

Arved Sandstrom

jross said:
Hi all,

I need to grab data from a database and populate an option value with
the results. I have have written some code already just need to know if
im on the right path. I'm using JDK1.4 and JBoss-2.4.4_Tomcat-3.2.3.

Here is my java class

http://pastebin.com/m4eea38f3

Here is my jsp

http://pastebin.com/m6435cc92

I'm wondering if I'm able to load the Hashmap ListStores.loadStore() in
the option value like I have done? will this populate the option value
with the sql results. I want less as possible java code in the jsp. Any
feedback would be great. I used pastebins because it seems the best way
to display code.

jross

My first thought would be, have you actually tried this? It'll answer
your question right away.

Think it through a bit though. You want the HTML to look something like

<select>
<option value="1">Value1</option>
<option value="2">Value2</option>
...
<option value="n">ValueN</option>
</select>

In your code you have a single <option> tag, there's no getting around
that. Furthermore, you don't even have visible text being displayed.

I haven't dealt with JSPs for many years - I do JSF, and this would be
handled with h:selectOneMenu in the page and a List of SelectItems in
the backing bean. In your case, I'd suggest locating a select tag that
someone has already written.

AHS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,260
Messages
2,571,038
Members
48,768
Latest member
first4landlord

Latest Threads

Top