Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using a List for Field Population

 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a remote table with users names. I have a JSP that has several fields for the user to fill in. Two of them are first and last name(the one logged on to the web app is not always the one whose name will go on the form). Can and if how would I set this up so the user could select the name from a list.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64685
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a <select> rather than a text field.
 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give me some idea of how to populate the drop down box dynamically with the result set of my remote connection?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64685
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "remote connection" I assume you mean a database?

Assuming that your web app is patterned using best-practice MVC patterns, it pretty straight-forward:
  • The page controller for the JSP will call a model class that retrieves the list from the DB.
  • If the list is not already in a suitable format, such as a List implementation, it should re-format the data as such
  • The page controller places the list in request scope as a scoped variable with a suitable name
  • On the JSP, the JSTL and EL are used to iterate over the list and create the options for the select element


  • If the options are to have values that are different from the displayed text, the list can be sets of name/value pairs.
    [ May 16, 2007: Message edited by: Bear Bibeault ]
     
    Steve Dyke
    Ranch Hand
    Posts: 1619
    1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Is it going to be possible to have one list with first name and last name and have that fill in two separate fields on the form?
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64685
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Two lists.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic