Populate data from a database into option values

Discussion in 'Java' started by jross, Jun 10, 2009.

  1. jross

    jross Guest

    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
     
    jross, Jun 10, 2009
    #1
    1. Advertising

  2. jross

    jross Guest

    jross wrote:
    > 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
     
    jross, Jun 10, 2009
    #2
    1. Advertising

  3. jross wrote:
    > 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
     
    Arved Sandstrom, Jun 11, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harry Zoroc
    Replies:
    1
    Views:
    980
    Gregory Vaughan
    Jul 12, 2004
  2. Enjoy Life
    Replies:
    2
    Views:
    303
    Roland Hall
    Feb 23, 2005
  3. jzhang29
    Replies:
    1
    Views:
    163
  4. jsd219
    Replies:
    1
    Views:
    117
    Peter Michaux
    Oct 17, 2007
  5. skywalker skywalker
    Replies:
    4
    Views:
    2,275
    Evertjan.
    Jul 22, 2011
Loading...

Share This Page