• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Using a List for Field Population

 
Ranch Hand
Posts: 2278
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a <select> rather than a text field.
 
Steve Dyke
Ranch Hand
Posts: 2278
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2278
    2
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Sheriff
    Posts: 67754
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Two lists.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic